package com.zjdiepu.www.manage.api.system;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import net.sf.jxls.exception.ParsePropertyException;
import net.sf.jxls.transformer.XLSTransformer;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.Workbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.dao.DataAccessException;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.core.RedisCallback;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.zjdiepu.www.base.BaseController;
import com.zjdiepu.www.base.annotation.Add;
import com.zjdiepu.www.base.annotation.Update;
import com.zjdiepu.www.base.core.AbstractSysUser;
import com.zjdiepu.www.base.core.ApiResponse;
import com.zjdiepu.www.base.core.PageVo;
import com.zjdiepu.www.base.enums.status.AddedStatus1;
import com.zjdiepu.www.base.enums.status.BusiStatus;
import com.zjdiepu.www.base.enums.status.DpStatus;
import com.zjdiepu.www.base.enums.status.PickCarStatus;
import com.zjdiepu.www.base.enums.status.RefundDepositStatus;
import com.zjdiepu.www.base.enums.status.RemitStatus;
import com.zjdiepu.www.base.enums.type.AttachmentLabel;
import com.zjdiepu.www.base.enums.type.AttachmentSort;
import com.zjdiepu.www.base.enums.type.AttachmentType;
import com.zjdiepu.www.base.enums.type.BusinessExtrasCodeType;
import com.zjdiepu.www.base.enums.type.BusinessExtrasType;
import com.zjdiepu.www.base.enums.type.DataDicType;
import com.zjdiepu.www.base.enums.type.ModeIDType;
import com.zjdiepu.www.base.enums.type.OperateType;
import com.zjdiepu.www.base.enums.type.ResultFlagType;
import com.zjdiepu.www.base.enums.type.SortFieldType;
import com.zjdiepu.www.base.enums.type.ThirdModeIDType;
import com.zjdiepu.www.common.util.CollectionInitUtil;
import com.zjdiepu.www.common.util.DateUtil;
import com.zjdiepu.www.common.util.NumberUtil;
import com.zjdiepu.www.commpent.RedisObjectClient;
import com.zjdiepu.www.commpent.ViewScopeControllerHelper;
import com.zjdiepu.www.commpent.mapper.base.DpBaseDealerInfoVoMapper;
import com.zjdiepu.www.commpent.mapper.cw.CwRemitCarVoMapper;
import com.zjdiepu.www.commpent.mapper.dh.DhInsuranceCompensationVoMapper;
import com.zjdiepu.www.commpent.mapper.dh.DhInsuranceCompulsoryVoMapper;
import com.zjdiepu.www.commpent.mapper.dh.DhInsuranceVoMapper;
import com.zjdiepu.www.commpent.mapper.dh.DhLoanAfterVoMapper;
import com.zjdiepu.www.commpent.mapper.dh.DzRegistrationVoMapper;
import com.zjdiepu.www.commpent.mapper.dz.DzGpsVoMapper;
import com.zjdiepu.www.commpent.mapper.dz.DzMortgageVoMapper;
import com.zjdiepu.www.commpent.mapper.yw.AbstractYwBusinessLoanVoNewMapper;
import com.zjdiepu.www.commpent.mapper.yw.YwBusinessBuyerVoMapper;
import com.zjdiepu.www.commpent.mapper.yw.YwBusinessCarVoMapper;
import com.zjdiepu.www.commpent.mapper.yw.YwBusinessDetailMapper;
import com.zjdiepu.www.commpent.mapper.yw.YwBusinessVoMapper;
import com.zjdiepu.www.commpent.mapper.yw.YwFeesVoMapper;
import com.zjdiepu.www.commpent.mapper.yw.ZxCrediQueryDetailMapper;
import com.zjdiepu.www.ibiz.base.IDpBaseDataDictionaryService;
import com.zjdiepu.www.ibiz.base.IDpBaseDealerInfoService;
import com.zjdiepu.www.ibiz.base.IOtherAttachmentsService;
import com.zjdiepu.www.ibiz.cache.ICachedDictionaryService;
import com.zjdiepu.www.ibiz.cw.ICwIncomeExpensesItemService;
import com.zjdiepu.www.ibiz.cw.ICwIncomeExpensesService;
import com.zjdiepu.www.ibiz.cw.ICwRefundCarService;
import com.zjdiepu.www.ibiz.cw.ICwRemitAdjustAService;
import com.zjdiepu.www.ibiz.cw.ICwRemitAdjustBService;
import com.zjdiepu.www.ibiz.cw.ICwRemitCarService;
import com.zjdiepu.www.ibiz.dh.IDhArchiveService;
import com.zjdiepu.www.ibiz.dh.IDhDepositMoneyService;
import com.zjdiepu.www.ibiz.dh.IDhInsuranceCompensationService;
import com.zjdiepu.www.ibiz.dh.IDhInsuranceCompulsoryService;
import com.zjdiepu.www.ibiz.dh.IDhInsuranceService;
import com.zjdiepu.www.ibiz.dh.IDhLoanAfterService;
import com.zjdiepu.www.ibiz.dh.IDhSettleService;
import com.zjdiepu.www.ibiz.dh.IOverdueService;
import com.zjdiepu.www.ibiz.dz.IDzGpsService;
import com.zjdiepu.www.ibiz.dz.IDzLendingService;
import com.zjdiepu.www.ibiz.dz.IDzLoanExitService;
import com.zjdiepu.www.ibiz.dz.IDzLoanMiddleAuditService;
import com.zjdiepu.www.ibiz.dz.IDzLoanMiddleBankService;
import com.zjdiepu.www.ibiz.dz.IDzMortgageService;
import com.zjdiepu.www.ibiz.dz.IDzMortgageSubService;
import com.zjdiepu.www.ibiz.dz.IDzPickCarService;
import com.zjdiepu.www.ibiz.dz.IDzRegistrationService;
import com.zjdiepu.www.ibiz.file.IQiniuFileService;
import com.zjdiepu.www.ibiz.icbc.IYwOrdernoBankService;
import com.zjdiepu.www.ibiz.other.IOtherAuditInfoService;
import com.zjdiepu.www.ibiz.partner.IThBusinessRecordService;
import com.zjdiepu.www.ibiz.partner.IThCreditResultService;
import com.zjdiepu.www.ibiz.partner.IThRepaymentScheduleService;
import com.zjdiepu.www.ibiz.partner.IThRepaymentService;
import com.zjdiepu.www.ibiz.partner.IThYwBusinessService;
import com.zjdiepu.www.ibiz.system.IBaseCustomerService;
import com.zjdiepu.www.ibiz.system.IBaseRemitAccountService;
import com.zjdiepu.www.ibiz.third.IJuheCityService;
import com.zjdiepu.www.ibiz.third.IJuheProvinceService;
import com.zjdiepu.www.ibiz.yw.IYwBusinessBuyerService;
import com.zjdiepu.www.ibiz.yw.IYwBusinessCarAreaPriceService;
import com.zjdiepu.www.ibiz.yw.IYwBusinessCarService;
import com.zjdiepu.www.ibiz.yw.IYwBusinessExtrasService;
import com.zjdiepu.www.ibiz.yw.IYwBusinessLoanService;
import com.zjdiepu.www.ibiz.yw.IYwBusinessService;
import com.zjdiepu.www.ibiz.yw.IYwFeesService;
import com.zjdiepu.www.ibiz.yw.IYwFeesSubService;
import com.zjdiepu.www.ibiz.yw.IYwFundApplyService;
import com.zjdiepu.www.ibiz.yw.IYwTransferService;
import com.zjdiepu.www.ibiz.zx.IZxCreditQueryService;
import com.zjdiepu.www.ibiz.zx.IZxQueryCreditApplySubService;
import com.zjdiepu.www.model.base.dto.DpBaseDataDictionary;
import com.zjdiepu.www.model.base.dto.DpBaseDealerInfo;
import com.zjdiepu.www.model.base.dto.OtherAttachments;
import com.zjdiepu.www.model.base.dto.SimpleDataDictionary;
import com.zjdiepu.www.model.base.dto.SysUser;
import com.zjdiepu.www.model.base.ext.DpBaseDataDictionaryExt;
import com.zjdiepu.www.model.base.response.XhhDownloadResponse;
import com.zjdiepu.www.model.cw.dto.CwIncomeExpenses;
import com.zjdiepu.www.model.cw.dto.CwRefundCar;
import com.zjdiepu.www.model.cw.dto.CwRemitAdjustA;
import com.zjdiepu.www.model.cw.dto.CwRemitAdjustB;
import com.zjdiepu.www.model.cw.dto.CwRemitCar;
import com.zjdiepu.www.model.cw.ext.CwIncomeExpensesExt;
import com.zjdiepu.www.model.cw.ext.CwRefundCarExt;
import com.zjdiepu.www.model.cw.ext.CwRemitCarExt;
import com.zjdiepu.www.model.cw.response.CwFundItem;
import com.zjdiepu.www.model.dh.dto.DhArchive;
import com.zjdiepu.www.model.dh.dto.DhDepositMoney;
import com.zjdiepu.www.model.dh.dto.DhInsurance;
import com.zjdiepu.www.model.dh.dto.DhInsuranceCompensation;
import com.zjdiepu.www.model.dh.dto.DhInsuranceCompulsory;
import com.zjdiepu.www.model.dh.dto.DhLoanAfter;
import com.zjdiepu.www.model.dh.dto.DhSettle;
import com.zjdiepu.www.model.dh.ext.DhArchiveExt;
import com.zjdiepu.www.model.dh.ext.DhInsuranceCompensationExt;
import com.zjdiepu.www.model.dh.ext.DhInsuranceCompulsoryExt;
import com.zjdiepu.www.model.dh.ext.DhInsuranceExt;
import com.zjdiepu.www.model.dh.ext.DhLoanAfterExt;
import com.zjdiepu.www.model.dh.ext.DhOverdueExt;
import com.zjdiepu.www.model.dh.ext.DhSettleExt;
import com.zjdiepu.www.model.dh.vo.DhOverdueVo;
import com.zjdiepu.www.model.dz.dto.DzGps;
import com.zjdiepu.www.model.dz.dto.DzLending;
import com.zjdiepu.www.model.dz.dto.DzLoanExit;
import com.zjdiepu.www.model.dz.dto.DzLoanMiddleAudit;
import com.zjdiepu.www.model.dz.dto.DzLoanMiddleBank;
import com.zjdiepu.www.model.dz.dto.DzMortgage;
import com.zjdiepu.www.model.dz.dto.DzMortgageSub;
import com.zjdiepu.www.model.dz.dto.DzPickCar;
import com.zjdiepu.www.model.dz.dto.DzRegistration;
import com.zjdiepu.www.model.dz.ext.DzGpsExt;
import com.zjdiepu.www.model.dz.ext.DzLoanExitExt;
import com.zjdiepu.www.model.dz.ext.DzLoanMiddleAuditExt;
import com.zjdiepu.www.model.dz.ext.DzLoanMiddleBankExt;
import com.zjdiepu.www.model.dz.ext.DzMortgageExt;
import com.zjdiepu.www.model.dz.ext.DzMortgageSubExt;
import com.zjdiepu.www.model.dz.ext.DzRegistrationExt;
import com.zjdiepu.www.model.icbc.dto.YwOrdernoBank;
import com.zjdiepu.www.model.icbc.ext.YwOrdernoBankExt;
import com.zjdiepu.www.model.other.dto.OtherAuditInfo;
import com.zjdiepu.www.model.other.ext.OtherAuditInfoExt;
import com.zjdiepu.www.model.partner.dto.ThBusinessRecord;
import com.zjdiepu.www.model.partner.dto.ThCreditResult;
import com.zjdiepu.www.model.partner.dto.ThRepayment;
import com.zjdiepu.www.model.partner.dto.ThRepaymentSchedule;
import com.zjdiepu.www.model.partner.dto.ThYwBusiness;
import com.zjdiepu.www.model.partner.ext.ThBusinessRecordExt;
import com.zjdiepu.www.model.partner.ext.ThCreditResultExt;
import com.zjdiepu.www.model.system.dto.BaseCustomer;
import com.zjdiepu.www.model.system.ext.BaseCustomerExt;
import com.zjdiepu.www.model.system.response.YearInsuranceMap;
import com.zjdiepu.www.model.yw.dto.YwBusiness;
import com.zjdiepu.www.model.yw.dto.YwBusinessBuyer;
import com.zjdiepu.www.model.yw.dto.YwBusinessCar;
import com.zjdiepu.www.model.yw.dto.YwBusinessCarAreaPrice;
import com.zjdiepu.www.model.yw.dto.YwBusinessExtras;
import com.zjdiepu.www.model.yw.dto.YwBusinessLoan;
import com.zjdiepu.www.model.yw.dto.YwFees;
import com.zjdiepu.www.model.yw.dto.YwFeesSub;
import com.zjdiepu.www.model.yw.dto.YwFundApply;
import com.zjdiepu.www.model.yw.ext.YwBusinessBuyerExt;
import com.zjdiepu.www.model.yw.ext.YwBusinessCarAreaPriceExt;
import com.zjdiepu.www.model.yw.ext.YwBusinessCarExt;
import com.zjdiepu.www.model.yw.ext.YwBusinessExtrasExt;
import com.zjdiepu.www.model.yw.ext.YwBusinessLoanExt;
import com.zjdiepu.www.model.yw.ext.YwFeesExt;
import com.zjdiepu.www.model.yw.ext.YwFeesSubExt;
import com.zjdiepu.www.model.yw.request.YwBusinessQueryRequest;
import com.zjdiepu.www.model.yw.response.YwBusinessDetail;
import com.zjdiepu.www.model.yw.response.YwBusinessInfoResponse;
import com.zjdiepu.www.model.zx.dto.ZxQueryCreditApplySub;
import com.zjdiepu.www.model.zx.ext.ZxQueryCreditApplySubExt;
import com.zjdiepu.www.model.zx.response.ZxCreditQueryDetail;
import com.zjdiepu.www.util.CachedEnums;
import com.zjdiepu.www.util.YwExtHelper;

/**
 * 客户Controller层<br/>
 * @author xiongxiaotun<br/>
 * @time 2017年04月24日 14时34分<br/>
 * @since 1.0<br/>
 */
@RestController
@RequestMapping(value= "BaseCustomerController", produces="application/json;charset=UTF-8")
@Api(tags = {"客户"}, produces="application/json;charset=UTF-8")
public class BaseCustomerController extends BaseController {
	private Logger logger = LoggerFactory.getLogger(getClass());
	@Resource
	private IYwOrdernoBankService ywOrdernoBankService;
    @Resource
    private IBaseCustomerService baseCustomerService;
    @Resource
    private IYwBusinessExtrasService ywBusinessExtrasService;
    @Resource
    private IDhSettleService dhSettleService;
    @Resource
    private IYwBusinessService ywBusinessService;
    @Resource
    private IYwFundApplyService ywFundApplyService;
    @Resource
    private ICwRefundCarService cwRefundCarService;
    @Resource
    private IDhLoanAfterService dhLoanAfterService;
    @Resource
    private IZxCreditQueryService zxCreditQueryService;
    @Resource
    private IZxQueryCreditApplySubService zxQueryCreditApplySubService;
    @Resource
    private IDhArchiveService dhArchiveService;
    @Resource
    private IDzLoanMiddleBankService dzLoanMiddleBankService;
    @Resource
    private IDzLoanMiddleAuditService dzLoanMiddleAuditService;
    @Resource
    private IDpBaseDataDictionaryService dBaseDataDictionaryService;
    @Resource
    private IYwFeesSubService ywFeesSubService;
    @Resource
    private ICwIncomeExpensesItemService cwIncomeExpensesItemService;
    @Resource
    private IDzLoanExitService dzLoanExitService;
    @Resource
    private ICwRemitCarService cwRemitCarService;
    @Resource
    private YwBusinessVoMapper ywBusinessVoMapper;
    @Resource
    private CwRemitCarVoMapper cwRemitCarVoMapper;
    @Resource
    private YwBusinessDetailMapper ywBusinessDetailMapper;
    @Resource
    private ZxCrediQueryDetailMapper zxCrediQueryDetailMapper;
    @Resource
    private ICachedDictionaryService cachedDictionaryService;
    @Resource
    private IYwBusinessBuyerService ywBusinessBuyerService;
    @Resource
    private YwBusinessBuyerVoMapper ywBusinessBuyerVoMapper;
    @Resource
    private IYwBusinessCarService ywBusinessCarService;
    @Resource
    private YwBusinessCarVoMapper ywBusinessCarVoMapper;
    @Resource
    private IYwBusinessLoanService ywBusinessLoanService;
    @Resource
    private AbstractYwBusinessLoanVoNewMapper ywBusinessLoanVoMapper;
    @Resource
    private IYwBusinessCarAreaPriceService ywBusinessCarAreaPriceService;
    @Resource
    private IDzLendingService dzLendingService;
    @Resource
    private IDzRegistrationService dzRegistrationService;
    @Resource
    private DzRegistrationVoMapper dzRegistrationVoMapper;
    @Resource
    private IDzGpsService dzGpsService;
    @Resource
    private IYwTransferService ywTransferService;
    @Resource
    private IDzMortgageService dzMortgageService;
    @Resource
    private IDzMortgageSubService dzMortgageSubService;
    @Resource
    private DzMortgageVoMapper dzMortgageVoMapper;
    @Resource
    private IYwFeesService ywFeesService;
    @Resource
    private YwFeesVoMapper ywFeesVoMapper;
    @Resource
    private IBaseRemitAccountService baseRemitAccountService;
    @Resource
    private IDpBaseDealerInfoService  dpBaseDealerInfoService;
    @Resource
    private DpBaseDealerInfoVoMapper  dpBaseDealerInfoVoMapper;
    @Resource
    private ICwIncomeExpensesService  cwincomeExpensesService;
    @Resource
    private DhLoanAfterVoMapper  dhLoanAfterVoMapper;
    @Resource
    private IDhInsuranceService  dhInsuranceService;
    @Resource
    private IDhInsuranceCompulsoryService  dhInsuranceCompulsoryService;
    @Resource
    private DhInsuranceVoMapper  dhInsuranceVoMapper;
    @Resource
    private DhInsuranceCompulsoryVoMapper  dhInsuranceCompulsoryVoMapper;
    @Resource
    private IDhInsuranceCompensationService  dhInsuranceCompensationService;
    @Resource
    private DhInsuranceCompensationVoMapper dhInsuranceCompensationVoMapper;
    @Resource
	private IOverdueService overdueService; 
    @Resource
    private IOtherAttachmentsService otherAttachmentsService; 
    @Resource
    private DzGpsVoMapper dzGpsVoMapper; 
    @Resource
    private IQiniuFileService qiniuFileService; 
    @Resource
    private IDzPickCarService dzPickCarService; 
    @Resource
    private IDhDepositMoneyService dhDepositMoneyService; 
    @Resource
    private RedisObjectClient redisObjectClient; 
    @Resource
    private IThCreditResultService thCreditResultService;
    @Resource
    private IThBusinessRecordService thBusinessRecordService;
    @Resource
    private IOtherAuditInfoService otherAuditInfoService;
    @Resource
    private ICwRemitAdjustAService cwRemitAdjustAService;
    @Resource
    private ICwRemitAdjustBService cwRemitAdjustBService;
    @Resource
    private IThYwBusinessService thYwBusinessService;
    @Resource
    private IThRepaymentService thRepaymentService;
    @Resource
    private IThRepaymentScheduleService thRepaymentScheduleService;
    @Resource
    private IJuheProvinceService juheProvinceService;
    @Resource
    private IJuheCityService juheCityService;
    
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: createRar <br/>
     * @Description: 生成RAR <br/>
     * @param busiId
     * @param applyId
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "生成RAR", response = Boolean.class, httpMethod="POST", tags={"生成RAR"})
    @ApiImplicitParams({
    	@ApiImplicitParam(name = "busiId", value = "业务主键", paramType="query", required = true, example="1"),
    	@ApiImplicitParam(name = "applyId", value = "征信申请主键", paramType="query", required = true, example="1")
    })
    @RequestMapping(value = "createRar", method = RequestMethod.POST)
    public ApiResponse createRar(String busiId, String applyId) {
    	if(StringUtils.isBlank(busiId) || StringUtils.isBlank(applyId) ) {
    		return ApiResponse.fail(ResultFlagType.PARAM_EMPTY);
    	}
    	qiniuFileService.saveRar(busiId, applyId);
    	return ApiResponse.success(true);
    }
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: createXhhRar <br/>
     * @Description: 生成鑫合汇RAR <br/>
     * @param busiId
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "生成鑫合汇RAR", response = Boolean.class, httpMethod="POST", tags={"生成RAR"})
    @ApiImplicitParams({
    	@ApiImplicitParam(name = "busiId", value = "业务主键", paramType="query", required = true, example="1"),
    })
    @RequestMapping(value = "createXhhRar", method = RequestMethod.POST)
    public ApiResponse createXhhRar(String busiId) {
    	if(StringUtils.isBlank(busiId) ) {
    		return ApiResponse.fail(ResultFlagType.PARAM_EMPTY);
    	}
    	qiniuFileService.xxhDataZip(busiId);
    	return ApiResponse.success(true);
    }
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: yuqiList <br/>
     * @Description: 历史记录 <br/>
     * @param busiId
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "历史记录", response = Boolean.class, httpMethod="POST", tags={"逾期记录"})
    @ApiImplicitParams({
    	@ApiImplicitParam(name = "busiId", value = "业务主键", paramType="query", required = true, example="1"),
    	@ApiImplicitParam(name = "targetIdNo", value = "省份证号", paramType="query", required = true, example="234234234234")
    })
    @RequestMapping(value = "historyLists", method = RequestMethod.POST)
    public ApiResponse historyLists(String busiId, String targetIdNo) {
    	//数据
    	Map<String, Object> result = CollectionInitUtil.emptyMap();
		if(StringUtils.isBlank(busiId)) {
			return ApiResponse.fail(ResultFlagType.PARAM_EMPTY);
		}
		YwBusiness ywBusiness = ywBusinessService.selectById(busiId);
		if(null == ywBusiness) {
			return ApiResponse.fail(ResultFlagType.MISSING);
		}
		String customerNo = ywBusiness.getCustomerNo();
		if(StringUtils.isBlank(customerNo)) {
			return ApiResponse.fail("999", "主借人身份证号为空");
		}
		String queryCreditApplyId = ywBusiness.getQueryCreditApplyId();
		if(StringUtils.isBlank(queryCreditApplyId)) {
			return ApiResponse.fail("999", "申请征信查询ID为空");
		}
		ZxQueryCreditApplySubExt zxQueryCreditApplySubExt = new ZxQueryCreditApplySubExt();
    	zxQueryCreditApplySubExt.setBaseWhere();
    	zxQueryCreditApplySubExt.withOutPage();
    	zxQueryCreditApplySubExt.setQueryCreditApplyId(queryCreditApplyId);
    	List<ZxQueryCreditApplySub> zxQueryCreditApplySubs = zxQueryCreditApplySubService.selectByExt(zxQueryCreditApplySubExt);
    	int i = 1;
    	for(ZxQueryCreditApplySub zxQueryCreditApplySub : zxQueryCreditApplySubs) {
    		String creditPeopleType = zxQueryCreditApplySub.getCreditPeopleType();
    		String cusNo = zxQueryCreditApplySub.getCusNo();
    		if("01".equals(creditPeopleType)) {
    			result.put("peiou_idno", cusNo);
    		} else if("02".equals(creditPeopleType)){
    			result.put("danbaoren" + i + "_idno", cusNo);
    			i++;
    		} else if("03".equals(creditPeopleType)) {
    			result.put("zhujieren_idno", cusNo);
    		}
    	}
        	
        if(StringUtils.isBlank(targetIdNo))	{ //没有传，则为主借人
        	targetIdNo = customerNo;
    	}
        
    	result.put("targetIdno", targetIdNo);
    	
    	ZxQueryCreditApplySubExt zxQueryCreditApplySubExt_ = new ZxQueryCreditApplySubExt();
    	zxQueryCreditApplySubExt_.setBaseWhere();
    	zxQueryCreditApplySubExt_.withOutPage();
    	zxQueryCreditApplySubExt_.setCusNo(targetIdNo);
    	List<ZxQueryCreditApplySub> zxQueryCreditApplySubs_ = zxQueryCreditApplySubService.selectByExt(zxQueryCreditApplySubExt_);
    	Set<String> names = CollectionInitUtil.emptySet();
    	
    	List<Map<String, Object>> records = CollectionInitUtil.emptyList();
    	redisObjectClient.execute(new RedisCallback<Boolean>() {
			@Override
			public Boolean doInRedis(RedisConnection redisConnection)
					throws DataAccessException {
				for(ZxQueryCreditApplySub zxQueryCreditApplySub : zxQueryCreditApplySubs_) {
					if(null == zxQueryCreditApplySub) {
						continue;
					}
					String queryCreditApplyId = zxQueryCreditApplySub.getQueryCreditApplyId();
					YwBusiness ywBusiness = new YwBusiness();
					ywBusiness.setDpStatus(DpStatus.NORMAL.getCode());
					ywBusiness.setQueryCreditApplyId(queryCreditApplyId);
					ywBusiness = ywBusinessService.selectRefined(ywBusiness);
					if(null == ywBusiness) {
						continue;
					}
					Map<String, Object> record = CollectionInitUtil.emptyMap();
					names.add(zxQueryCreditApplySub.getCusName());
					
					record.put("replaceId", ywBusiness.getId());
					record.put("submitTime", DateUtil.dateTo8String3(ywBusiness.getSubmitTime()));
					String creditPeopleType = zxQueryCreditApplySub.getCreditPeopleType();
					if(StringUtils.isNotBlank(creditPeopleType)) {
						SimpleDataDictionary creditPeopleTypeDic = redisObjectClient.hGet(redisConnection, SimpleDataDictionary.class.getSimpleName(), creditPeopleType, DataDicType.CREDIT_PEOPLE_TYPE.getCode());
						record.put("creditPeopleType", null == creditPeopleTypeDic ? "" : creditPeopleTypeDic.getName());
					} else {
						record.put("creditPeopleType", "");
					}
					record.put("cusName", ywBusiness.getCustomerName());
					record.put("cusNo", ywBusiness.getCustomerNo());
					Integer busiStatus = ywBusiness.getBusiStatus();
					record.put("busiStatus", (String)CachedEnums.getValue(busiStatus, BusiStatus.class));
					record.put("signLoanAmount", NumberUtil.format(ywBusiness.getSignLoanAmount(), 2));
					String carType = ywBusiness.getCarType();
					if(StringUtils.isNotBlank(carType)) {
						SimpleDataDictionary carTypeDic = redisObjectClient.hGet(redisConnection, SimpleDataDictionary.class.getSimpleName(), carType, DataDicType.CAR_TYPE.getCode());
						record.put("carType", null == carTypeDic ? "" : carTypeDic.getName());
					} else {
						record.put("carType", "");
					}
					String bankLoan = ywBusiness.getBankLoan();
					if(StringUtils.isNotBlank(bankLoan)) {
						SimpleDataDictionary bankLoanDic = redisObjectClient.hGet(redisConnection, SimpleDataDictionary.class.getSimpleName(), bankLoan, DataDicType.LOAN_BANK.getCode());
						record.put("bankLoan", null == bankLoanDic ? "" : bankLoanDic.getName());
					} else {
						record.put("bankLoan", "");
					}
					records.add(record);
				}
				return true;
			}
		});
    	
    	records.sort(new Comparator<Map<String, Object>>() {
			@Override
			public int compare(Map<String, Object> record, Map<String, Object> targetRecord) {
				String submitTime = (String)record.get("submitTime");
				if(StringUtils.isBlank(submitTime)) {
					return 1;
				}
				String targetSubmitTime = (String)targetRecord.get("submitTime");
				if(StringUtils.isBlank(targetSubmitTime)) {
					return -1;
				}
				return DateUtil.countDiffDays(DateUtil.StringToDate(targetSubmitTime), DateUtil.StringToDate(submitTime));
			}
		});
    	result.put("rows", records);
    	result.put("page", 1);
    	int total = 0;
    	int pageSize = 10000;
    	int records_ = records.size();
    	if (0 == records_) {
    		total = 0;
		}
		if (records_ % pageSize == 0) {
			total = (int)records_ / pageSize;
		} else {
			total = (int)records_ / pageSize + 1;
		}
    	result.put("total", total);
    	result.put("records", records_);
    	
    	result.put("targetCusName", StringUtils.join(names, ","));
		return ApiResponse.success(result);
    }
    /**
     * @author xiongxiaotun <br/>
     * @Title: yuqiList <br/>
     * @Description: 逾期记录 <br/>
     * @param busiId
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "逾期记录", response = Boolean.class, httpMethod="POST", tags={"逾期记录"})
    @ApiImplicitParams({
    	@ApiImplicitParam(name = "busiId", value = "业务主键", paramType="query", required = true, example="1")
    })
    @RequestMapping(value = "yuqiList", method = RequestMethod.POST)
    public ApiResponse yuqiList(DhOverdueExt dhOverdueExt) {
    	if(StringUtils.isBlank(dhOverdueExt.getBusiId())) {
    		return ApiResponse.fail(ResultFlagType.PARAM_EMPTY);
    	}
    	dhOverdueExt.setBaseWhere();
    	dhOverdueExt.setBusiId(dhOverdueExt.getBusiId());
    	if(StringUtils.isBlank(dhOverdueExt.getSidx())) {
    		dhOverdueExt.setSidx("dateOverdue");
    		dhOverdueExt.setSord("ASC");
    	}
    	dhOverdueExt.withOutPage();
    	PageVo page = getPage(dhOverdueExt);
    	int records = overdueService.countByExt(dhOverdueExt);
		page.setRecords(records);
		if (records > 0) {
            List<DhOverdueVo> dhOverdues = overdueService.selectByExt(dhOverdueExt);
            page.setRows(dhOverdues);
        } else {
            page.setRows(CollectionInitUtil.emptyList());
        }
    	return ApiResponse.success(page);
    }
    /**
     * @author xiongxiaotun <br/>
     * @Title: chuxianDetail <br/>
     * @Description: 出险记录 <br/>
     * @param busiId
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "出险记录", response = Boolean.class, httpMethod="POST", tags={"出险记录"})
    @ApiImplicitParams({
    	@ApiImplicitParam(name = "busiId", value = "业务主键", paramType="query", required = true, example="1"),
    	@ApiImplicitParam(name = "compensationId", value = "出险主键", paramType="query", required = true, example="1")
    })
    @RequestMapping(value = "chuxianDetail", method = RequestMethod.POST)
    public ApiResponse chuxianDetail(String busiId, String compensationId) {
    	if(StringUtils.isBlank(busiId) && StringUtils.isBlank(compensationId)) {
    		return ApiResponse.fail(ResultFlagType.PARAM_EMPTY);
    	}
    	Map<String, Object> response = CollectionInitUtil.emptyMap();
    	DhInsuranceCompensation dhInsuranceCompensation = null;
    	if(StringUtils.isNotBlank(busiId)) {
    		/*出险*/
    		DhInsuranceCompensationExt dhInsuranceCompensationExt = new DhInsuranceCompensationExt();
    		dhInsuranceCompensationExt.setBaseWhere();
    		dhInsuranceCompensationExt.withOutPage();
    		dhInsuranceCompensationExt.setBusiId(busiId);
    		dhInsuranceCompensationExt.setOrderSql("`DATE_COMPENSATION` DESC");
    		List<DhInsuranceCompensation> dhInsuranceCompensations = dhInsuranceCompensationService.selectByExt(dhInsuranceCompensationExt);
    		if(CollectionUtils.isNotEmpty(dhInsuranceCompensations)){
    			Map<String, String> years = CollectionInitUtil.emptyMap();
    			for(DhInsuranceCompensation dhInsuranceCompensation_: dhInsuranceCompensations) {
    				years.put(DateUtil.dateTo8String3(dhInsuranceCompensation_.getDateCompensation()), dhInsuranceCompensation_.getId());
    			}
    			
    			
    			response.put("years", years);
    			
    			dhInsuranceCompensation = dhInsuranceCompensations.get(0);
    			compensationId = dhInsuranceCompensation.getId();
    		}
    	}
    	
    	if(StringUtils.isNotBlank(compensationId)) {
    		if(null == dhInsuranceCompensation) {
    			dhInsuranceCompensation = dhInsuranceCompensationService.selectById(compensationId);
    		}
    	}
    	
    	if(null != dhInsuranceCompensation) {
    		dhInsuranceCompensationVoMapper.mapper(dhInsuranceCompensation);
    		response.put("dhInsuranceCompensation", dhInsuranceCompensation);
    		
    		busiId = dhInsuranceCompensation.getBusiId();
    		//客户
    		YwBusiness ywBusiness = ywBusinessService.selectById(busiId);
    		if(ywBusiness != null) {
    			response.put("customerName", ywBusiness.getCustomerName());
    		}
    		//车牌号
    		DzRegistrationExt dzRegistrationExt = new DzRegistrationExt();
    		dzRegistrationExt.setBaseWhere();
    		dzRegistrationExt.setRows(1);
    		dzRegistrationExt.setBusiId(busiId);
    		List<DzRegistration> dzRegistrations = dzRegistrationService.selectByExt(dzRegistrationExt);
    		if(CollectionUtils.isNotEmpty(dzRegistrations)){
    			DzRegistration dzRegistration = dzRegistrations.get(0);
    			if(dzRegistration != null) {
    				response.put("registrationNumber", dzRegistration.getRegistrationNumber());
    			}
    		}
    		
    		
    	}
    	
    	return ApiResponse.success(response);
    }
    /**
     * @author xiongxiaotun <br/>
     * @Title: baoxianDetail <br/>
     * @Description: 相关保险 <br/>
     * @param busiId
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "相关保险", response = Boolean.class, httpMethod="POST", tags={"相关保险"})
    @ApiImplicitParams({
    	@ApiImplicitParam(name = "busiId", value = "业务主键", paramType="query", required = true, example="1"),
    	@ApiImplicitParam(name = "insurancesId", value = "保险单主键", paramType="query", required = true, example="1")
    })
    @RequestMapping(value = "baoxianDetail", method = RequestMethod.POST)
    public ApiResponse baoxianDetail(String busiId, String insurancesId) {
    	if(StringUtils.isBlank(busiId) && StringUtils.isBlank(insurancesId)) {
    		return ApiResponse.fail(ResultFlagType.PARAM_EMPTY);
    	}
    	Map<String, Object> response = CollectionInitUtil.emptyMap();
    	DhInsurance dhInsurance = null;
    	if(StringUtils.isNotBlank(busiId)) {
    		/*保险*/
    		DhInsuranceExt dhInsuranceExt = new DhInsuranceExt();
    		dhInsuranceExt.setBaseWhere();
    		dhInsuranceExt.withOutPage();
    		dhInsuranceExt.setBusiId(busiId);
    		dhInsuranceExt.setOrderSql("`YEAR`");
    		List<DhInsurance> dhInsurances = dhInsuranceService.selectByExt(dhInsuranceExt);
    		if(CollectionUtils.isNotEmpty(dhInsurances)){
    			List<YearInsuranceMap> years = CollectionInitUtil.emptyList();
    			for(DhInsurance dhInsurance_: dhInsurances) {
    				if(dhInsurance_.getYear() != null && StringUtils.isNotBlank(dhInsurance_.getId())) {
    					YearInsuranceMap yearInsuranceMap = new YearInsuranceMap();
    					yearInsuranceMap.setYear(dhInsurance_.getYear());
    					yearInsuranceMap.setInsuranceId(dhInsurance_.getId());
    					years.add(yearInsuranceMap);
    				}
    			}
    			response.put("years", years);
    			
    			dhInsurance = dhInsurances.get(0);
    			insurancesId = dhInsurance.getId();
    		}
    	}
    	
    	if(StringUtils.isNotBlank(insurancesId)) {
    		if(null == dhInsurance) {
    			dhInsurance = dhInsuranceService.selectById(insurancesId);
    		}
    		//依附于保险的强险
			DhInsuranceCompulsoryExt dhInsuranceCompulsoryExt = new DhInsuranceCompulsoryExt();
			dhInsuranceCompulsoryExt.setBaseWhere();
			dhInsuranceCompulsoryExt.setRows(1);
			dhInsuranceCompulsoryExt.setInsuranceId(insurancesId);
			dhInsuranceCompulsoryExt.setBusiId(busiId);
			List<DhInsuranceCompulsory> dhInsuranceCompulsorys = dhInsuranceCompulsoryService.selectByExt(dhInsuranceCompulsoryExt);
			if(CollectionUtils.isNotEmpty(dhInsuranceCompulsorys)){
				DhInsuranceCompulsory dhInsuranceCompulsory = dhInsuranceCompulsorys.get(0);
				dhInsuranceCompulsoryVoMapper.mapper(dhInsuranceCompulsory);
				response.put("dhInsuranceCompulsory", dhInsuranceCompulsory);
			}
    	}
    	
    	if(null != dhInsurance) {
    		dhInsuranceVoMapper.mapper(dhInsurance);
    		response.put("dhInsurance", dhInsurance);
    	}
    	
    	return ApiResponse.success(response);
    }
    /**
     * @author xiongxiaotun <br/>
     * @Title: yewliDetail <br/>
     * @Description: 贷后信息<br/>
     * @param busiId
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "贷后信息", response = Boolean.class, httpMethod="POST", tags={"贷后信息"})
    @ApiImplicitParams({
    	@ApiImplicitParam(name = "busiId", value = "业务主键", paramType="query", required = true, example="1")
    })
    @RequestMapping(value = "yewliDetail", method = RequestMethod.POST)
    public ApiResponse yewliDetail(String busiId) {
    	if(StringUtils.isBlank(busiId)) {
    		return ApiResponse.fail(ResultFlagType.PARAM_EMPTY);
    	}
    	Map<String, Object> response = CollectionInitUtil.emptyMap();
    	/*贷后信息登记*/
    	DhLoanAfterExt dhLoanAfterExt = new DhLoanAfterExt();
    	dhLoanAfterExt.setBaseWhere();
    	dhLoanAfterExt.setRows(1);
    	dhLoanAfterExt.setBusiId(busiId);
    	List<DhLoanAfter> dhLoanAfters = dhLoanAfterService.selectByExt(dhLoanAfterExt);
    	if(CollectionUtils.isNotEmpty(dhLoanAfters)) {
    		DhLoanAfter dhLoanAfter = dhLoanAfters.get(0);
    		dhLoanAfterVoMapper.mapper(dhLoanAfter);
    		response.put("dhLoanAfter", dhLoanAfter);
    	}
    	
    	return ApiResponse.success(response);
    }
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: shouZhiDetail <br/>
     * @Description: 收支管理<br/>
     * @param busiId
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "收支管理", response = Boolean.class, httpMethod="POST", tags={"收支管理"})
    @ApiImplicitParams({
    	@ApiImplicitParam(name = "busiId", value = "业务主键", paramType="query", required = true, example="1")
    })
    @RequestMapping(value = "shouZhiDetail", method = RequestMethod.POST)
    public ApiResponse shouZhiDetail(String busiId) {
    	if(StringUtils.isBlank(busiId)) {
    		return ApiResponse.fail(ResultFlagType.PARAM_EMPTY);
    	}
    	Map<String, Object> response = CollectionInitUtil.emptyMap();
    	// 收支管理信息
    	CwIncomeExpensesExt cwIncomeExpensesExt = new CwIncomeExpensesExt();
		cwIncomeExpensesExt.setBaseWhere();
		cwIncomeExpensesExt.setRows(1);
		cwIncomeExpensesExt.setBusiId(busiId);
		List<CwIncomeExpenses> cwIncomeExpenses = cwincomeExpensesService.selectByExt(cwIncomeExpensesExt);
		if(CollectionUtils.isNotEmpty(cwIncomeExpenses)) {
			response.put("cwIncomeExpenses", cwIncomeExpenses.get(0));
		}
		
    	return ApiResponse.success(response);
    }
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: dakuanDetail <br/>
     * @Description: 财务打款详情<br/>
     * @param busiId
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "财务打款详情", response = Boolean.class, httpMethod="POST", tags={"财务打款详情"})
    @ApiImplicitParams({
    	@ApiImplicitParam(name = "busiId", value = "业务主键", paramType="query", required = true, example="1")
    })
    @RequestMapping(value = "dakuanDetail", method = RequestMethod.POST)
    public ApiResponse dakuanDetail(String busiId) {
    	if(StringUtils.isBlank(busiId)) {
    		return ApiResponse.fail(ResultFlagType.PARAM_EMPTY);
    	}
    	Map<String, Object> response = CollectionInitUtil.emptyMap();
    	// 查询车辆&车贷信息
    	YwBusinessCarExt ywBusinessCarExt = new YwBusinessCarExt();
		ywBusinessCarExt.setBaseWhere();
		ywBusinessCarExt.setRows(1);// 只能返回一条数据
		ywBusinessCarExt.setBusiId(busiId);
    	List<YwBusinessCar> ywBusinessCars = ywBusinessCarService.selectByExt(ywBusinessCarExt);
		if (CollectionUtils.isNotEmpty(ywBusinessCars)) {
			YwBusinessCar ywBusinessCar = ywBusinessCars.get(0);
			ywBusinessCarVoMapper.mapper(ywBusinessCar);
			response.put("ywBusinessCar", ywBusinessCar);
			
			String carId = ywBusinessCar.getId();
			// 查询车辆&车贷信息 
			YwBusinessLoanExt ywBusinessLoanExt = new YwBusinessLoanExt();
			ywBusinessLoanExt.setBaseWhere();
			ywBusinessLoanExt.setRows(1);// 只能返回一条数据
			ywBusinessLoanExt.setBusiId(busiId);
			ywBusinessLoanExt.setCarId(carId);
			List<YwBusinessLoan> ywBusinessLoans = ywBusinessLoanService.selectByExt(ywBusinessLoanExt);
			if (CollectionUtils.isNotEmpty(ywBusinessLoans)) {
				YwBusinessLoan ywBusinessLoan = ywBusinessLoans.get(0);
				ywBusinessLoanVoMapper.mapper(ywBusinessLoan);
				response.put("ywBusinessLoan", ywBusinessLoan);
			}
		}
		
		/*按揭日报表*/
		YwFeesExt ywFeesExt = new YwFeesExt();
    	ywFeesExt.setBaseWhere();
    	ywFeesExt.setRows(1);
    	ywFeesExt.setBusiId(busiId);
    	List<YwFees> ywFeeses = ywFeesService.selectByExt(ywFeesExt);
    	if(CollectionUtils.isNotEmpty(ywFeeses)) {
    		YwFees ywFees = ywFeeses.get(0);
    		ywFeesVoMapper.mapper(ywFees);
    		response.put("ywFees", ywFees);
    		
//    		BaseRemitAccount remitAccount = baseRemitAccountService.selectById(ywFees.getReceiverId());
//    		response.put("remitAccount", remitAccount);
    	}
    	
//    	获取费用数据字典=====================
    	    	DpBaseDataDictionaryExt dpBaseDataDictionaryExt = new DpBaseDataDictionaryExt();
    	    	dpBaseDataDictionaryExt.setBaseWhere();
    	    	dpBaseDataDictionaryExt.withOutPage();
    	    	dpBaseDataDictionaryExt.setParentValue(DataDicType.FUND_ITEM.getCode());
    	    	dpBaseDataDictionaryExt.setAddedValue1("01"); //启用的明细
    	    	dpBaseDataDictionaryExt.setOrderSql("`VALUE`");
//    			只展示附加值为1的数据
    	    	List<DpBaseDataDictionary> dpBaseDataDictionarys = dBaseDataDictionaryService.selectByExt(dpBaseDataDictionaryExt);
    	    	
    	    	DpBaseDataDictionaryExt depositItemExt = new DpBaseDataDictionaryExt();
    	    	depositItemExt.setBaseWhere();
    	    	depositItemExt.setRows(1);
    	    	depositItemExt.setParentValue(DataDicType.FUND_ITEM.getCode());
    	    	depositItemExt.setValue("35");
    	    	List<DpBaseDataDictionary> depositDataDictionaryItems = dBaseDataDictionaryService.selectByExt(depositItemExt);
    	    	if(CollectionUtils.isNotEmpty(depositDataDictionaryItems)) {
    	    		dpBaseDataDictionarys.add(depositDataDictionaryItems.get(0));
    	    	} else {
    	    		DpBaseDataDictionary dpBaseDataDictionary = new DpBaseDataDictionary();
    	    		dpBaseDataDictionary.setValue("35");
    	    		dpBaseDataDictionary.setName("征信押金");
    	    		dpBaseDataDictionary.setParentValue(DataDicType.FUND_ITEM.getCode());
    	    		dpBaseDataDictionarys.add(dpBaseDataDictionary);
    	    	}
    	    	depositItemExt.setBaseWhere();
    	    	depositItemExt.setRows(1);
    	    	depositItemExt.setParentValue(DataDicType.FUND_ITEM.getCode());
    	    	depositItemExt.setValue("01");
    	    	List<DpBaseDataDictionary> depositDataDictionaryItems_ = dBaseDataDictionaryService.selectByExt(depositItemExt);
    	    	if(CollectionUtils.isNotEmpty(depositDataDictionaryItems_)) {
    	    		dpBaseDataDictionarys.add(depositDataDictionaryItems_.get(0));
    	    	} else {
    	    		DpBaseDataDictionary dpBaseDataDictionary = new DpBaseDataDictionary();
    	    		dpBaseDataDictionary.setValue("01");
    	    		dpBaseDataDictionary.setName("按揭服务费");
    	    		dpBaseDataDictionary.setParentValue(DataDicType.FUND_ITEM.getCode());
    	    		dpBaseDataDictionarys.add(dpBaseDataDictionary);
    	    	}
//    	    	获取费用数据字典=====================
    	    	
    	    	
//    	    	==================应收获取============================
    	    	List<Map<String, Double>> fees = ywFeesSubService.countReceiveByBusiId(busiId, null);
//    	    	==================应收获取============================
    	    	
//    	    	==================已收获取============================   	
    	    	List<String> exludeKeys = Arrays.asList(new String[]{"01", "35"});
    	    	List<CwFundItem> fundItems = CollectionInitUtil.emptyList();
    	    	List<CwFundItem> fundItems_ = CollectionInitUtil.emptyList();
    	    	List<Map<String, Double>> remits = cwIncomeExpensesItemService.countReceiveByBusiId(busiId, null);
    	    	if(CollectionUtils.isNotEmpty(dpBaseDataDictionarys)) {
    	    		for(DpBaseDataDictionary dpBaseDataDictionary : dpBaseDataDictionarys) {
    	    			CwFundItem cwFundItem = new CwFundItem();
    	    			String key = dpBaseDataDictionary.getValue();
    	    			cwFundItem.setKey(key);
    	    			cwFundItem.setName(dpBaseDataDictionary.getName());
    	    			cwFundItem.setFeeCount(ViewScopeControllerHelper.getItem(fees, key));
    	    			cwFundItem.setRemitCount(ViewScopeControllerHelper.getItem(remits, key));
    	    			if(exludeKeys.contains(key)) {
    	    				fundItems_.add(cwFundItem);
    	    			} else {
    	    				fundItems.add(cwFundItem);
    	    			}
    	    		}
    	    	}
//    	    	==================已收获取============================  
    	    	response.put("fundItems", fundItems);
    	    	response.put("fundItems_", fundItems_);
    	    	
    	    	CwFundItem cwFundItem = new CwFundItem();
    	    	cwFundItem.setFeeCount(ViewScopeControllerHelper.countItems(fees, null));
    	    	cwFundItem.setRemitCount(ViewScopeControllerHelper.countItems(remits, null));
    	    	response.put("fundTotal", cwFundItem);
    	
		YwBusiness ywBusiness = ywBusinessService.selectById(busiId);
		if(ywBusiness != null && StringUtils.isNotBlank(ywBusiness.getDealerId())) {
			//经销商
			DpBaseDealerInfo dpBaseDealerInfo = dpBaseDealerInfoService.selectById(ywBusiness.getDealerId());
			dpBaseDealerInfoVoMapper.mapper(dpBaseDealerInfo);
			response.put("dpBaseDealerInfo", dpBaseDealerInfo);
			
			/*最近打款*/
			CwRemitCarExt cwRemitCarExt = new CwRemitCarExt();
			cwRemitCarExt.setBaseWhere();
			cwRemitCarExt.setRows(1);
			cwRemitCarExt.setBusiId(busiId);
			cwRemitCarExt.setStatusRemit(RemitStatus.YI_TI_JIAO.getCode());
			cwRemitCarExt.setOrderSql("`MODIFIED` DESC");
			List<CwRemitCar> cwRemitCars = cwRemitCarService.selectByExt(cwRemitCarExt);
			if(CollectionUtils.isNotEmpty(cwRemitCars)) {
				CwRemitCar cwRemitCar = cwRemitCars.get(0);
				cwRemitCarVoMapper.mapper(cwRemitCar);
				response.put("cwRemitCar", cwRemitCar);
			}
		}
		/*打款历史*/
		String history = cwRemitCarService.queryHistoryByBusiId(busiId);
		response.put("history", StringUtils.isBlank(history)?"-":(history.startsWith(",")?history.substring(1):history));
		
    	return ApiResponse.success(response);
    }
    /**
     * @param busiId
     * @return
     */
    @ApiOperation(value = "查询汽车信息",response = Map.class, httpMethod="POST", tags={"查询"})
    @RequestMapping(value = "getCarsLoanInfo", method = RequestMethod.POST)
    public Map<String,Object> getCarsLoanInfo(String busiId) {
    	Map<String,Object> response=success();
    	YwBusinessCarExt ywBusinessCarExt = new YwBusinessCarExt();
		ywBusinessCarExt.setBaseWhere();
		ywBusinessCarExt.setRows(1);// 只能返回一条数据
		ywBusinessCarExt.setBusiId(busiId);
    	List<YwBusinessCar> ywBusinessCars = ywBusinessCarService.selectByExt(ywBusinessCarExt);
		if (CollectionUtils.isNotEmpty(ywBusinessCars)) {
			YwBusinessCar ywBusinessCar = ywBusinessCars.get(0);
			ywBusinessCarVoMapper.mapper(ywBusinessCar);
			response.put("ywBusinessCar", ywBusinessCar);
			
			String carId = ywBusinessCar.getId();
			// 查询车辆&车贷信息 
			YwBusinessLoanExt ywBusinessLoanExt = new YwBusinessLoanExt();
			ywBusinessLoanExt.setBaseWhere();
			ywBusinessLoanExt.setRows(1);// 只能返回一条数据
			ywBusinessLoanExt.setBusiId(busiId);
			ywBusinessLoanExt.setCarId(carId);
			List<YwBusinessLoan> ywBusinessLoans = ywBusinessLoanService.selectByExt(ywBusinessLoanExt);
			if (CollectionUtils.isNotEmpty(ywBusinessLoans)) {
				YwBusinessLoan ywBusinessLoan = ywBusinessLoans.get(0);
				ywBusinessLoanVoMapper.mapper(ywBusinessLoan);
				response.put("ywBusinessLoan", ywBusinessLoan);
			}
			DzRegistrationExt dzRegistrationExt=new DzRegistrationExt();
			dzRegistrationExt.setBaseWhere();
			dzRegistrationExt.setRows(1);
			dzRegistrationExt.setBusiId(busiId);
			dzRegistrationExt.setCarId(carId);
			List<DzRegistration> listRegistration=dzRegistrationService.selectByExt(dzRegistrationExt);
			if (CollectionUtils.isNotEmpty(listRegistration)) {
				DzRegistration registration=listRegistration.get(0);
				response.put("dzRegistration", registration);
			}
		}
		return response;
		
	}
	/**
     * @author xiongxiaotun <br/>
     * @Title: baobiaoDetail <br/>
     * @Description: 按揭日报表详情<br/>
     * @param busiId
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "按揭日报表详情", response = Boolean.class, httpMethod="POST", tags={"按揭日报表详情"})
    @ApiImplicitParams({
    	@ApiImplicitParam(name = "busiId", value = "业务主键", paramType="query", required = true, example="1")
    })
    @RequestMapping(value = "baobiaoDetail", method = RequestMethod.POST)
    public ApiResponse baobiaoDetail(String busiId) {
    	if(StringUtils.isBlank(busiId)) {
    		return ApiResponse.fail(ResultFlagType.PARAM_EMPTY);
    	}
    	Map<String, Object> response = CollectionInitUtil.emptyMap();
    	YwFeesExt ywFeesExt = new YwFeesExt();
    	ywFeesExt.setBaseWhere();
    	ywFeesExt.setRows(1);
    	ywFeesExt.setBusiId(busiId);
    	List<YwFees> ywFeeses = ywFeesService.selectByExt(ywFeesExt);
    	if(CollectionUtils.isNotEmpty(ywFeeses)) {
    		YwFees ywFees = ywFeeses.get(0);
    		ywFeesVoMapper.mapper(ywFees);
    		response.put("ywFees", ywFees);
    		
//    		BaseRemitAccount remitAccount = baseRemitAccountService.selectById(ywFees.getReceiverId());
//    		response.put("remitAccount", remitAccount);
    	}
    	

//    	获取费用数据字典=====================
    	DpBaseDataDictionaryExt dpBaseDataDictionaryExt = new DpBaseDataDictionaryExt();
    	dpBaseDataDictionaryExt.setBaseWhere();
    	dpBaseDataDictionaryExt.withOutPage();
    	dpBaseDataDictionaryExt.setParentValue(DataDicType.FUND_ITEM.getCode());
    	dpBaseDataDictionaryExt.setAddedValue1("01"); //启用的明细
    	dpBaseDataDictionaryExt.setOrderSql("`VALUE`");
//		只展示附加值为1的数据
    	List<DpBaseDataDictionary> dpBaseDataDictionarys = dBaseDataDictionaryService.selectByExt(dpBaseDataDictionaryExt);
    	
    	DpBaseDataDictionaryExt depositItemExt = new DpBaseDataDictionaryExt();
    	depositItemExt.setBaseWhere();
    	depositItemExt.setRows(1);
    	depositItemExt.setParentValue(DataDicType.FUND_ITEM.getCode());
    	depositItemExt.setValue("35");
    	List<DpBaseDataDictionary> depositDataDictionaryItems = dBaseDataDictionaryService.selectByExt(depositItemExt);
    	if(CollectionUtils.isNotEmpty(depositDataDictionaryItems)) {
    		dpBaseDataDictionarys.add(depositDataDictionaryItems.get(0));
    	} else {
    		DpBaseDataDictionary dpBaseDataDictionary = new DpBaseDataDictionary();
    		dpBaseDataDictionary.setValue("35");
    		dpBaseDataDictionary.setName("征信押金");
    		dpBaseDataDictionary.setParentValue(DataDicType.FUND_ITEM.getCode());
    		dpBaseDataDictionarys.add(dpBaseDataDictionary);
    	}
    	depositItemExt.setBaseWhere();
    	depositItemExt.setRows(1);
    	depositItemExt.setParentValue(DataDicType.FUND_ITEM.getCode());
    	depositItemExt.setValue("01");
    	List<DpBaseDataDictionary> depositDataDictionaryItems_ = dBaseDataDictionaryService.selectByExt(depositItemExt);
    	if(CollectionUtils.isNotEmpty(depositDataDictionaryItems_)) {
    		dpBaseDataDictionarys.add(depositDataDictionaryItems_.get(0));
    	} else {
    		DpBaseDataDictionary dpBaseDataDictionary = new DpBaseDataDictionary();
    		dpBaseDataDictionary.setValue("01");
    		dpBaseDataDictionary.setName("按揭服务费");
    		dpBaseDataDictionary.setParentValue(DataDicType.FUND_ITEM.getCode());
    		dpBaseDataDictionarys.add(dpBaseDataDictionary);
    	}
//    	获取费用数据字典=====================
    	
    	
//    	==================应收获取============================
    	List<Map<String, Double>> fees = ywFeesSubService.countReceiveByBusiId(busiId, null);
//    	==================应收获取============================
    	
//    	==================已收获取============================   	
    	List<String> exludeKeys = Arrays.asList(new String[]{"01", "35"});
    	List<CwFundItem> fundItems = CollectionInitUtil.emptyList();
    	List<CwFundItem> fundItems_ = CollectionInitUtil.emptyList();
    	List<Map<String, Double>> remits = cwIncomeExpensesItemService.countReceiveByBusiId(busiId, null);
    	if(CollectionUtils.isNotEmpty(dpBaseDataDictionarys)) {
    		for(DpBaseDataDictionary dpBaseDataDictionary : dpBaseDataDictionarys) {
    			CwFundItem cwFundItem = new CwFundItem();
    			String key = dpBaseDataDictionary.getValue();
    			cwFundItem.setKey(key);
    			cwFundItem.setName(dpBaseDataDictionary.getName());
    			cwFundItem.setFeeCount(ViewScopeControllerHelper.getItem(fees, key));
    			cwFundItem.setRemitCount(ViewScopeControllerHelper.getItem(remits, key));
    			if(exludeKeys.contains(key)) {
    				fundItems_.add(cwFundItem);
    			} else {
    				fundItems.add(cwFundItem);
    			}
    		}
    	}
//    	==================已收获取============================  
    	response.put("fundItems", fundItems);
    	response.put("fundItems_", fundItems_);
    	
    	CwFundItem cwFundItem = new CwFundItem();
    	cwFundItem.setFeeCount(ViewScopeControllerHelper.countItems(fees, null));
    	cwFundItem.setRemitCount(ViewScopeControllerHelper.countItems(remits, null));
    	response.put("fundTotal", cwFundItem);
    	
    	int size = fundItems.size();
    	int tableCount =  size % 7 == 0 ? size / 7 : size / 7 + 1;
    	response.put("tableCount", tableCount);
    	return ApiResponse.success(response);
    }
    /**
     * @author xiongxiaotun <br/>
     * @Title: diyaDetail <br/>
     * @Description: 抵押详情<br/>
     * @param busiId
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "抵押详情", response = Boolean.class, httpMethod="POST", tags={"抵押详情"})
    @ApiImplicitParams({
    	@ApiImplicitParam(name = "busiId", value = "业务主键", paramType="query", required = true, example="1")
    })
    @RequestMapping(value = "diyaDetail", method = RequestMethod.POST)
    public ApiResponse diyaDetail(String busiId) {
    	if(StringUtils.isBlank(busiId)) {
    		return ApiResponse.fail(ResultFlagType.PARAM_EMPTY);
    	}
    	Map<String, Object> response = CollectionInitUtil.emptyMap();
    	// 查询抵押详情
    	DzMortgageExt dzMortgageExt = new DzMortgageExt();
    	dzMortgageExt.setBaseWhere();
    	dzMortgageExt.setRows(1);
    	dzMortgageExt.setBusiId(busiId);
    	List<DzMortgage> dzMortgages = dzMortgageService.selectByExt(dzMortgageExt);
    	if(CollectionUtils.isNotEmpty(dzMortgages)) {
    		DzMortgage dzMortgage = dzMortgages.get(0);
    		dzMortgageVoMapper.mapper(dzMortgage);
    		response.put("dzMortgage", dzMortgage);
    	}
    	
    	DzMortgageSubExt dzMortgageSubExt = new DzMortgageSubExt();
		dzMortgageSubExt.setBaseWhere();
		dzMortgageSubExt.setRows(1);
		dzMortgageSubExt.setBusiId(busiId);
		List<DzMortgageSub> dzMortgageSubs = dzMortgageSubService.selectByExt(dzMortgageSubExt);
		if(CollectionUtils.isNotEmpty(dzMortgageSubs)) {
			DzMortgageSub dzMortgageSub = dzMortgageSubs.get(0);
    		response.put("dzMortgageSub", dzMortgageSub);
    	}
		
		// 查询车辆&车贷信息
		YwBusinessCarExt ywBusinessCarExt = new YwBusinessCarExt();
		ywBusinessCarExt.setBaseWhere();
		ywBusinessCarExt.setRows(1);// 只能返回一条数据
		ywBusinessCarExt.setBusiId(busiId);
		List<YwBusinessCar> ywBusinessCars = ywBusinessCarService.selectByExt(ywBusinessCarExt);
		if (CollectionUtils.isNotEmpty(ywBusinessCars)) {
			YwBusinessCar ywBusinessCar = ywBusinessCars.get(0);
			ywBusinessCarVoMapper.mapper(ywBusinessCar);
			response.put("ywBusinessCar", ywBusinessCar);

			String carId = ywBusinessCar.getId();
			// 查询车辆&车贷信息 
			YwBusinessLoanExt ywBusinessLoanExt = new YwBusinessLoanExt();
			ywBusinessLoanExt.setBaseWhere();
			ywBusinessLoanExt.setRows(1);// 只能返回一条数据
			ywBusinessLoanExt.setBusiId(busiId);
			ywBusinessLoanExt.setCarId(carId);
			List<YwBusinessLoan> ywBusinessLoans = ywBusinessLoanService.selectByExt(ywBusinessLoanExt);
			if (CollectionUtils.isNotEmpty(ywBusinessLoans)) {
				YwBusinessLoan ywBusinessLoan = ywBusinessLoans.get(0);
				ywBusinessLoanVoMapper.mapper(ywBusinessLoan);
				response.put("ywBusinessLoan", ywBusinessLoan);
			}
		}
		
    	return ApiResponse.success(response);
    }
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: gpsDetail <br/>
     * @Description: GPS详情<br/>
     * @param busiId
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "GPS详情", response = Boolean.class, httpMethod="POST", tags={"GPS详情"})
    @ApiImplicitParams({
    	@ApiImplicitParam(name = "busiId", value = "业务主键", paramType="query", required = true, example="1")
    })
    @RequestMapping(value = "gpsDetail", method = RequestMethod.POST)
    public ApiResponse gpsDetail(String busiId) {
    	if(StringUtils.isBlank(busiId)) {
    		return ApiResponse.fail(ResultFlagType.PARAM_EMPTY);
    	}
    	Map<String, Object> response = CollectionInitUtil.emptyMap();
    	// 查询GPS信息
    	DzGpsExt dzGpsExt = new DzGpsExt();
    	dzGpsExt.setBaseWhere();
    	dzGpsExt.withOutPage();
    	dzGpsExt.setBusiId(busiId);
    	List<DzGps> dzGpses = dzGpsService.selectByExt(dzGpsExt);
    	dzGpsVoMapper.mapper(dzGpses);
    	response.put("dzGpses", dzGpses);
    	return ApiResponse.success(response);
    }
    /**
     * @author xiongxiaotun <br/>
     * @Title: cheDetail <br/>
     * @Description: 车辆&车牌详情<br/>
     * @param busiId
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "车辆&车牌详情", response = Boolean.class, httpMethod="POST", tags={"车辆&车牌详情"})
    @ApiImplicitParams({
        @ApiImplicitParam(name = "busiId", value = "业务主键", paramType="query", required = true, example="1")
    })
    @RequestMapping(value = "cheDetail", method = RequestMethod.POST)
    public ApiResponse cheDetail(String busiId) {
    	if(StringUtils.isBlank(busiId)) {
    		return ApiResponse.fail(ResultFlagType.PARAM_EMPTY);
    	}
    	Map<String, Object> response = CollectionInitUtil.emptyMap();
    	YwBusiness ywBusiness = ywBusinessService.selectById(busiId);
    	if(null == ywBusiness) {
    		return ApiResponse.fail(ResultFlagType.MISSING);
    	}
    	response.put("ywBusiness", ywBusiness);
    	
    	// 查询车辆&车贷信息
		YwBusinessCarExt ywBusinessCarExt = new YwBusinessCarExt();
		ywBusinessCarExt.setBaseWhere();
		ywBusinessCarExt.setRows(1);// 只能返回一条数据
		ywBusinessCarExt.setBusiId(busiId);
		List<YwBusinessCar> ywBusinessCars = ywBusinessCarService.selectByExt(ywBusinessCarExt);
		if (CollectionUtils.isNotEmpty(ywBusinessCars)) {
			YwBusinessCar ywBusinessCar = ywBusinessCars.get(0);
			ywBusinessCarVoMapper.mapper(ywBusinessCar);
			response.put("ywBusinessCar", ywBusinessCar);
			
			DzRegistrationExt dzRegistrationExt = new DzRegistrationExt();
			dzRegistrationExt.setBaseWhere();
			dzRegistrationExt.setRows(1);
			dzRegistrationExt.setBusiId(busiId);
			dzRegistrationExt.setCarId(ywBusinessCar.getId());
			List<DzRegistration> dzRegistrations = dzRegistrationService.selectByExt(dzRegistrationExt);
			if(CollectionUtils.isNotEmpty(dzRegistrations)){
				DzRegistration dzRegistration = dzRegistrations.get(0);
				dzRegistrationVoMapper.mapper(dzRegistration);
				response.put("dzRegistration", dzRegistration);
			}
		}
		//过户信息
//		@update 2017-07-25 xiongxiaotun 过户时间从主表获取，意义为：新车提车/二手车过户时间
//		YwTransferExt ywTransferExt = new YwTransferExt();
//		ywTransferExt.setBaseWhere();
//		ywTransferExt.setBusiId(busiId);
//		ywTransferExt.setRows(1);
//		List<YwTransfer> ywTransfers = ywTransferService.selectByExt(ywTransferExt);
//		if(CollectionUtils.isNotEmpty(ywTransfers)) {
//			YwTransfer ywTransfer = ywTransfers.get(0);
//			if(ywTransfer != null) {
//				response.put("ywTransfer", ywTransfer);
//			}
//		}
		
        return ApiResponse.success(response);
    }
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: gcrDetail  <br/>
     * @Description: 车辆&车贷详情<br/>
     * @param busiId
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "车辆&车贷详情", response = Boolean.class, httpMethod="POST", tags={"车辆&车贷详情"})
    @ApiImplicitParams({
        @ApiImplicitParam(name = "busiId", value = "业务主键", paramType="query", required = true, example="1")
    })
    @RequestMapping(value = "chlxxDetail", method = RequestMethod.POST)
    public ApiResponse chlxxDetail(String busiId) {
    	if(StringUtils.isBlank(busiId)) {
    		return ApiResponse.fail(ResultFlagType.PARAM_EMPTY);
    	}
    	
    	YwBusinessInfoResponse response = new YwBusinessInfoResponse();
    	// 查询车辆&车贷信息
		YwBusinessCarExt ywBusinessCarExt = new YwBusinessCarExt();
		ywBusinessCarExt.setBaseWhere();
		ywBusinessCarExt.setRows(1);// 只能返回一条数据
		ywBusinessCarExt.setBusiId(busiId);
		List<YwBusinessCar> ywBusinessCars = ywBusinessCarService.selectByExt(ywBusinessCarExt);
		if (CollectionUtils.isNotEmpty(ywBusinessCars)) {
			YwBusinessCar ywBusinessCar = ywBusinessCars.get(0);
			ywBusinessCarVoMapper.mapper(ywBusinessCar);
			response.setYwBusinessCar(ywBusinessCar);

			String carId = ywBusinessCar.getId();
			// 查询车辆&车贷信息 //只能返回一条数据
			YwBusinessLoanExt ywBusinessLoanExt = new YwBusinessLoanExt();
			ywBusinessLoanExt.setBaseWhere();
			ywBusinessLoanExt.setRows(1);// 只能返回一条数据
			ywBusinessLoanExt.setBusiId(busiId);
			ywBusinessLoanExt.setCarId(carId);
			List<YwBusinessLoan> ywBusinessLoans = ywBusinessLoanService.selectByExt(ywBusinessLoanExt);
			if (CollectionUtils.isNotEmpty(ywBusinessLoans)) {
				YwBusinessLoan ywBusinessLoan = ywBusinessLoans.get(0);
				ywBusinessLoan.setCarType(ywBusinessCar.getCarType());
				ywBusinessLoanVoMapper.mapper(ywBusinessLoan);
				response.setYwBusinessLoan(ywBusinessLoan);
			}
			
			//估价
			YwBusinessCarAreaPriceExt ywBusinessCarAreaPriceExt = new YwBusinessCarAreaPriceExt();
			ywBusinessCarAreaPriceExt.setBaseWhere();
			ywBusinessCarAreaPriceExt.withOutPage();
			ywBusinessCarAreaPriceExt.setBusiId(busiId);
			ywBusinessCarAreaPriceExt.setCarId(carId);
			ywBusinessCarAreaPriceExt.setOrderSql("`AREA_ID` ASC");
			List<YwBusinessCarAreaPrice> ywBusinessCarAreaPrices = ywBusinessCarAreaPriceService.selectByExt(ywBusinessCarAreaPriceExt);
			if(CollectionUtils.isNotEmpty(ywBusinessCarAreaPrices)) {
				StringBuilder sb = new StringBuilder();
				sb.append("经评估，该二手车估价 ");
				for(YwBusinessCarAreaPrice ywBusinessCarAreaPrice : ywBusinessCarAreaPrices) {
					String price = ywBusinessCarAreaPrice.getPrice();
					sb.append(' ').append(ywBusinessCarAreaPrice.getAreaName()).append('：').append(price).append(NumberUtil.isNumber(price)?'万':"");
				}
				response.setCarAreaPrice(sb.toString());
			}
		}
        return ApiResponse.success(response);
    }
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: gcrDetail  <br/>
     * @Description: 购车人详情<br/>
     * @param busiId
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "购车人详情", response = Boolean.class, httpMethod="POST", tags={"购车人详情"})
    @ApiImplicitParams({
        @ApiImplicitParam(name = "busiId", value = "业务主键", paramType="query", required = true, example="1")
    })
    @RequestMapping(value = "gcrDetail", method = RequestMethod.POST)
    public ApiResponse gcrDetail(String busiId) {
    	if(StringUtils.isBlank(busiId)) {
    		return ApiResponse.fail(ResultFlagType.PARAM_EMPTY);
    	}
    	
    	YwBusinessInfoResponse response = new YwBusinessInfoResponse();
    	// 查询购车人信息
		YwBusinessBuyerExt ywBusinessBuyerExt = new YwBusinessBuyerExt();
		ywBusinessBuyerExt.setBaseWhere();
		ywBusinessBuyerExt.setBusiId(busiId);
		ywBusinessBuyerExt.withOutPage();
		List<YwBusinessBuyer> ywBusinessBuyers = ywBusinessBuyerService
				.selectByExt(ywBusinessBuyerExt);
		for (YwBusinessBuyer ywBusinessBuyer : ywBusinessBuyers) {
			ywBusinessBuyerVoMapper.mapper(ywBusinessBuyer);
			String carManType = ywBusinessBuyer.getCarManType();
			SimpleDataDictionary cachedDataDic = cachedDictionaryService.getCachedDataDic(carManType, DataDicType.CREDIT_PEOPLE_TYPE);
			if (null != cachedDataDic) {
				response.addYwBusinessBuyer(cachedDataDic.getValue(),
						ywBusinessBuyer);
			}
		}
        return ApiResponse.success(response);
    }
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: zxcxDetail  <br/>
     * @Description: 征信详情<br/>
     * @param busiId
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "征信详情", response = Boolean.class, httpMethod="POST", tags={"征信详情"})
    @ApiImplicitParams({
        @ApiImplicitParam(name = "queryCreditApplyId", value = "征信查询申请主键", paramType="query", required = true, example="1")
    })
    @RequestMapping(value = "zxcxDetail", method = RequestMethod.POST)
    public ApiResponse zxcxDetail(String queryCreditApplyId) {
    	if(StringUtils.isBlank(queryCreditApplyId)) {
    		return ApiResponse.fail(ResultFlagType.PARAM_EMPTY);
    	}
    	YwBusinessInfoResponse response = new YwBusinessInfoResponse();
		List<ZxCreditQueryDetail> zxCrediQueryDetails = zxCreditQueryService.selectMultiByApplyId(queryCreditApplyId);
		zxCrediQueryDetailMapper.mapper(zxCrediQueryDetails);
		response.setZxCreditQuerys(zxCrediQueryDetails);
		int i = 1;
		for (ZxCreditQueryDetail zxCrediQueryDetail : zxCrediQueryDetails) {
			String creditPeopleType = zxCrediQueryDetail.getCreditPeopleType();
			String cusNo = zxCrediQueryDetail.getCusNo();
			if("01".equals(creditPeopleType)) {
				response.setCusNoPeiOu(cusNo);
			} else if("03".equals(creditPeopleType)) {
				response.setCusNo(cusNo);
			} else if("02".equals(creditPeopleType)) {
				if(i == 1) {
					response.setCusNoDanBaoRen1(cusNo);
				} else if(i == 2) {
					response.setCusNoDanBaoRen2(cusNo);
				} else if(i == 3) {
					response.setCusNoDanBaoRen3(cusNo);
				} else if(i == 4) {
					response.setCusNoDanBaoRen4(cusNo);
				}
				i++;
			}
		}
		/*for (ZxCreditQueryDetail zxCrediQueryDetail : zxCrediQueryDetails) {
			String creditPeopleType = zxCrediQueryDetail
					.getCreditPeopleType();
			SimpleDataDictionary cachedDataDic = cachedDictionaryService.getCachedDataDic(creditPeopleType, DataDicType.CREDIT_PEOPLE_TYPE);
			if (null != cachedDataDic) {
				response.addZxCreditQuery(cachedDataDic.getValue(), zxCrediQueryDetail);
			}
		}*/
        return ApiResponse.success(response);
    }
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: ywBusinessExtrasDetail  <br/>
     * @Description: 附件信息 <br/>
     * @param busiId
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "综合信息", response = Boolean.class, httpMethod="POST", tags={"综合信息"})
    @ApiImplicitParams({
        @ApiImplicitParam(name = "busiId", value = "业务主键", paramType="query", required = true, example="1")
    })
    @RequestMapping(value = "zhxxDetail", method = RequestMethod.POST)
    public ApiResponse zhxxDetail(String busiId) {
    	if(StringUtils.isBlank(busiId)) {
    		return ApiResponse.fail(ResultFlagType.PARAM_EMPTY);
    	}
    	Map<String, Object> result = CollectionInitUtil.emptyMap();
    	/*垫提车款*/
    	CwRemitCarExt cwRemitCarExt = new CwRemitCarExt();
    	cwRemitCarExt.setBaseWhere();
    	cwRemitCarExt.setBusiId(busiId);
    	cwRemitCarExt.setOrderSql("`CREATED`");
    	cwRemitCarExt.withOutPage();
    	List<CwRemitCar> cwRemitCars = cwRemitCarService.selectByExt(cwRemitCarExt);
    	if(CollectionUtils.isNotEmpty(cwRemitCars)) {
    		for(CwRemitCar cwRemitCar : cwRemitCars) {
    			cwRemitCarVoMapper.mapper(cwRemitCar);
    			/*退提车款*/
    			CwRefundCarExt cwRefundCarExt = new CwRefundCarExt();
    			cwRefundCarExt.setBaseWhere();
    			cwRefundCarExt.setBusiId(busiId);
    			cwRefundCarExt.setRows(1);
    			cwRefundCarExt.setRemitId(cwRemitCar.getId());
    			List<CwRefundCar> cwRefundCars = cwRefundCarService.selectByExt(cwRefundCarExt);
    			if(CollectionUtils.isNotEmpty(cwRefundCars)) {
    				cwRemitCar.setCwRefundCar(cwRefundCars.get(0));
    			} else {
    				CwRemitCar tempCwRemitCar = new CwRemitCar(); 
    				BeanUtils.copyProperties(cwRemitCar, tempCwRemitCar);
    				result.put("cwRemitCar", tempCwRemitCar);
    			}
    		}
    		result.put("cwRemitCars", cwRemitCars);
    	}
    	/*结清*/
    	DhSettleExt dhSettleExt = new DhSettleExt();
    	dhSettleExt.setBaseWhere();
    	dhSettleExt.setBusiId(busiId);
    	dhSettleExt.setRows(1);
    	List<DhSettle> dhSettles = dhSettleService.selectByExt(dhSettleExt);
    	if(CollectionUtils.isNotEmpty(dhSettles)) {
    		result.put("dhSettle", dhSettles.get(0));
    	}
    	/*贷后信息登记*/
    	DhLoanAfterExt dhLoanAfterExt = new DhLoanAfterExt();
    	dhLoanAfterExt.setBaseWhere();
    	dhLoanAfterExt.setRows(1);
    	dhLoanAfterExt.setBusiId(busiId);
    	List<DhLoanAfter> dhLoanAfters = dhLoanAfterService.selectByExt(dhLoanAfterExt);
    	if(CollectionUtils.isNotEmpty(dhLoanAfters)) {
    		result.put("dhLoanAfter", dhLoanAfters.get(0));
    	}
    	/*银行放款*/
    	DzLending dzLending = new DzLending();
    	dzLending.setDpStatus(DpStatus.NORMAL.getCode());
    	dzLending.setBusiId(busiId);
    	dzLending = dzLendingService.selectRefined(dzLending);
    	if(null != dzLending) {
    		result.put("dzLending", dzLending);
    	}
    	
    	/*贷中信息登记：银行*/
    	DzLoanMiddleBankExt dzLoanMiddleBankExt = new DzLoanMiddleBankExt();
    	dzLoanMiddleBankExt.setBaseWhere();
    	dzLoanMiddleBankExt.setRows(1);
    	dzLoanMiddleBankExt.setBusiId(busiId);
    	List<DzLoanMiddleBank> dzLoanMiddleBanks = dzLoanMiddleBankService.selectByExt(dzLoanMiddleBankExt);
    	if(CollectionUtils.isNotEmpty(dzLoanMiddleBanks)) {
    		result.put("dzLoanMiddleBank", dzLoanMiddleBanks.get(0));
    	}
    	/*贷中信息登记：风控*/
    	DzLoanMiddleAuditExt dzLoanMiddleAuditExt = new DzLoanMiddleAuditExt();
    	dzLoanMiddleAuditExt.setBaseWhere();
    	dzLoanMiddleAuditExt.setRows(1);
    	dzLoanMiddleAuditExt.setBusiId(busiId);
    	List<DzLoanMiddleAudit> dzLoanMiddleAudits = dzLoanMiddleAuditService.selectByExt(dzLoanMiddleAuditExt);
    	if(CollectionUtils.isNotEmpty(dzLoanMiddleAudits)) {
    		result.put("dzLoanMiddleAudit", dzLoanMiddleAudits.get(0));
    	}
    	/*资料归档*/
    	DhArchiveExt dhArchiveExt = new DhArchiveExt();
    	dhArchiveExt.setBaseWhere();
    	dhArchiveExt.setRows(1);
    	dhArchiveExt.setBusiId(busiId);
    	List<DhArchive> dhArchives = dhArchiveService.selectByExt(dhArchiveExt);
    	if(CollectionUtils.isNotEmpty(dhArchives)) {
    		result.put("dhArchive", dhArchives.get(0));
    	}
    	/*退贷*/
    	DzLoanExitExt dzLoanExitExt = new DzLoanExitExt();
    	dzLoanExitExt.setBaseWhere();
    	dzLoanExitExt.setRows(1);
    	dzLoanExitExt.setBusiId(busiId);
    	List<DzLoanExit> dzLoanExits = dzLoanExitService.selectByExt(dzLoanExitExt);
    	if(CollectionUtils.isNotEmpty(dzLoanExits)) {
    		result.put("dzLoanExit", dzLoanExits.get(0));
    	}
        return ApiResponse.success(result);
    }
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: ywBusinessDetail  <br/>
     * @Description: 业务详情<br/>
     * @param busiId
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "业务详情", response = Boolean.class, httpMethod="POST", tags={"业务详情"})
    @ApiImplicitParams({
        @ApiImplicitParam(name = "busiId", value = "业务主键", paramType="query", required = true, example="1")
    })
    @RequestMapping(value = "ywBusinessDetail", method = RequestMethod.POST)
    public ApiResponse ywBusinessDetail(String busiId) {
    	if(StringUtils.isBlank(busiId)) {
    		return ApiResponse.fail(ResultFlagType.PARAM_EMPTY);
    	}
    	Map<String, Object> result = CollectionInitUtil.emptyMap();
    	YwBusinessDetail ywBusinessDetail = ywBusinessService.getMultiById(busiId);
    	
    	DhArchive dhArchive = new DhArchive();
    	dhArchive.setBusiId(busiId);
    	dhArchive.setDpStatus(DpStatus.NORMAL.getCode());
    	dhArchive = dhArchiveService.selectRefined(dhArchive);
    	if(null != dhArchive) {
    		ywBusinessDetail.setNoRecord(dhArchive.getNoRecord());
    	}
    	
    	OtherAttachments otherAttachments = new OtherAttachments();
    	otherAttachments.setDpStatus(DpStatus.NORMAL.getCode());
    	otherAttachments.setAttachmentSort(AttachmentSort.YE_WU_FU_JIAN_DA_BAO.getCode());
    	otherAttachments.setFileLabel(AttachmentLabel.YE_WU_FU_JIAN_DA_BAO.getCode());
    	otherAttachments.setAttachmentType(AttachmentType.RAR.getCode());
    	otherAttachments.setDataid(busiId);
    	otherAttachments = otherAttachmentsService.selectRefined(otherAttachments);
    	/**
    	 * 操作类型
    	 * 1：暂无
    	 * 2: 生成中
    	 * 3：下载
    	 * 4：生成
    	 */
    	if(null == otherAttachments) {
    		ywBusinessDetail.setOperationType(1);   //不能生成
    		ywBusinessDetail.setOperationName("暂无");
    	} else {
    		String ossPath = otherAttachments.getOssPath();
    		if(StringUtils.isBlank(ossPath)) {
    			ywBusinessDetail.setOperationType(2);   //生成中
    			ywBusinessDetail.setOperationName("生成中");
    		} else {
    			if(qiniuFileService.exists(ossPath)){
    				ywBusinessDetail.setOperationType(3); //下载RAR
    				ywBusinessDetail.setOperationName("下载");
    				String rarUrl = qiniuFileService.getURL(ossPath);
    				ywBusinessDetail.setRarName(ossPath);
    				ywBusinessDetail.setRarOssPath(rarUrl);
    			} else {
    				ywBusinessDetail.setOperationType(4); //重新生成
    				ywBusinessDetail.setOperationName("生成");
    			}
    		}
    	}
    	
		OtherAttachments otherAttachments_ = new OtherAttachments();
		otherAttachments_.setDataid(busiId);
		otherAttachments_.setDpStatus(DpStatus.NORMAL.getCode());
		otherAttachments_.setAttachmentSort(AttachmentSort.XHH_FU_JIAN_DA_BAO.getCode());
		otherAttachments_.setFileLabel(AttachmentLabel.XHH_DA_BAO_RAR_LABEL.getCode());
		otherAttachments_.setAttachmentType(AttachmentType.RAR.getCode());
		otherAttachments_ = otherAttachmentsService.selectRefined(otherAttachments_);
		/**
		 * 操作类型
		 * 1：暂无
		 * 2: 生成中
		 * 3：下载
		 * 4：生成
		 */
		if(null == otherAttachments_) {
			ywBusinessDetail.setXhhOperationType(1);   //不能生成
			ywBusinessDetail.setXhhOperationName("暂无");
		} else {
			String ossPath = otherAttachments_.getOssPath();
			if(StringUtils.isBlank(ossPath)) {
				ywBusinessDetail.setXhhOperationType(2);   //生成中
				ywBusinessDetail.setXhhOperationName("生成中");
			} else {
				if(qiniuFileService.exists(ossPath)){
					ywBusinessDetail.setXhhOperationType(3); //下载RAR
					ywBusinessDetail.setXhhOperationName("下载");
					String rarUrl = qiniuFileService.getURL(ossPath);
					ywBusinessDetail.setXhhRarName(ossPath);
					ywBusinessDetail.setXhhRarOssPath(rarUrl);
				} else {
					ywBusinessDetail.setXhhOperationType(4); //重新生成
					ywBusinessDetail.setXhhOperationName("生成");
				}
			}
		}
    	
    	ywBusinessDetailMapper.mapper(ywBusinessDetail);
    	//业务详情
    	result.put("ywBusinessDetail", ywBusinessDetail);
    	
    	/*
    	 * 提车状态
    	 * 0：未提车
    	 * 1：提车中
    	 * 2：已提车
    	 * 3：二手车
    	 */
    	Integer pickCarStatus = 0; //未提车
    	String carType = ywBusinessDetail.getCarType();
    	Integer busiStatus = ywBusinessDetail.getBusiStatus();
    	Date pickCarTime = ywBusinessDetail.getPickCarTime();
    	if("01".equals(carType)) {
    		if(BusiStatus.SHEN_PI_WAN_CHENG.getCode() <= busiStatus) {
    			DzPickCar dzPickCar = new DzPickCar();
    			dzPickCar.setDpStatus(DpStatus.NORMAL.getCode());
    			dzPickCar.setBusiId(busiId);
    			DzPickCar dzPickCar_ = dzPickCarService.selectRefined(dzPickCar);
    			if(null == dzPickCar_) {
    				pickCarStatus = 0;
    			} else {
    				Integer pickCarStatus_ = dzPickCar_.getPickCarStatus();
    				if(PickCarStatus.YI_SHEN_HE.getCode() == pickCarStatus_ && pickCarTime != null){
    					pickCarStatus = 2; //已经审核：通过
    				}/* else if(PickCarStatus.YI_SHEN_HE.getCode()==pickCarStatus_ && pickCarTime == null){
    					pickCarStatus = 2; //已经审核：不通过
	    			}*/ else {
	    				pickCarStatus = 1; //待审核
	    			}
    			}
    			
    		}
    	} else {
    		pickCarStatus = 3; //二手车
    	}
    	result.put("pickCarStatus", pickCarStatus);
    	
    	/*
    	 * 车牌登记状态
    	 * 0：未提车
    	 * 1：提车中
    	 * 2：已提车
    	 */
    	Integer registrationPlatesStatus = 0; //未登记
    	Date licensePlateTime = ywBusinessDetail.getLicensePlateTime();
    	if(busiStatus >=  BusiStatus.SHEN_PI_WAN_CHENG.getCode() && busiStatus <= BusiStatus.YIN_HANG_YI_FANG_KUAN.getCode()) {
    		if(licensePlateTime == null){
    			registrationPlatesStatus = 1;//登记中
    		} else {
    			registrationPlatesStatus = 2;//已登记
    		}
    	}
    	result.put("registrationPlatesStatus", registrationPlatesStatus);
    	
    	/*
    	 * 抵押状态
    	 * 0：未抵押
    	 * 1：抵押中
    	 * 2：已抵押
    	 */
    	Integer pledgeStatus = 0; //未抵押
    	Date pledgeTime = ywBusinessDetail.getPledgeTime();
    	if(busiStatus >=  BusiStatus.SHEN_PI_WAN_CHENG.getCode() && busiStatus <= BusiStatus.YIN_HANG_YI_FANG_KUAN.getCode()) {
    		if(pledgeTime == null){
    			pledgeStatus = 1;//抵押中
    		} else {
    			pledgeStatus = 2;//已抵押
    		}
    	}
    	result.put("pledgeStatus", pledgeStatus);
    	
    	/*
    	 * 按期还款状态
    	 * 0：不需要还款
    	 * 1：还款中
    	 */
    	Integer lendingStatus = 0; //未抵押
    	Date timeLending = ywBusinessDetail.getTimeLending();
		if(timeLending == null){
			pledgeStatus = 0;//不需要还款
		} else {
			pledgeStatus = 1;//还款中
		}
    	result.put("lendingStatus", lendingStatus);
    	/*
    	 * 退押金状态
    	 * 0：没有退押金审核
    	 * 1：退押金审核中
    	 * 2：退押金催收审核
    	 * 3：退押金续保审核
    	 * 4：退押金审核完成
    	 */
    	Integer depositMoneyStatus = 0; //未抵押
    	DhDepositMoney dhDepositMoney = new DhDepositMoney();
    	dhDepositMoney.setDpStatus(DpStatus.NORMAL.getCode());
    	dhDepositMoney.setBusiId(busiId);
    	DhDepositMoney dhDepositMoney_ = dhDepositMoneyService.selectRefined(dhDepositMoney);
    	if(dhDepositMoney_ == null){
    		depositMoneyStatus = 0;//没有退押金审核
    	} else {
    		Integer statusRefundDeposit = dhDepositMoney_.getStatusRefundDeposit();
    		if(RefundDepositStatus.YI_SHEN_QIN.getCode().equals(statusRefundDeposit)) {
    			depositMoneyStatus = 1;//退押金审核中
    		} else if(RefundDepositStatus.CUI_SHOU_YI_SHEN_HE.getCode().equals(statusRefundDeposit)){
    			depositMoneyStatus = 2;//催收已审核
    		} else if(RefundDepositStatus.XU_BAO_YI_SHEN_HE.getCode().equals(statusRefundDeposit)){
    			depositMoneyStatus = 3;//续保已审核
    		} else if(RefundDepositStatus.YI_TUI_KUAN.getCode().equals(statusRefundDeposit)){
    			depositMoneyStatus = 4;//已退款
    		}
    	}
    	result.put("depositMoneyStatus", depositMoneyStatus);
    	
    	OtherAuditInfoExt otherAuditInfoExt = new OtherAuditInfoExt();
    	otherAuditInfoExt.setBaseWhere();
    	otherAuditInfoExt.setRows(1);
    	otherAuditInfoExt.setBusiId(busiId);
    	otherAuditInfoExt.setAuditStatusValueType("BusiStatus");
    	otherAuditInfoExt.setOrderSql("`CREATED` DESC");
    	otherAuditInfoExt.setWhereSql("`AUDIT_STATUS_VALUE` <= " + BusiStatus.TUI_DAI.getCode());
    	List<OtherAuditInfo> otherAuditInfos = otherAuditInfoService.selectByExt(otherAuditInfoExt);
    	if(CollectionUtils.isNotEmpty(otherAuditInfos)) {
    		result.put("lastBusiStatus", otherAuditInfos.get(0).getAuditStatusValue());
    	}
    	
    	//附加信息
    	YwBusinessExtrasExt ywBusinessExtrasExt = new YwBusinessExtrasExt();
    	ywBusinessExtrasExt.withOutPage();
    	ywBusinessExtrasExt.setBaseWhere();
    	ywBusinessExtrasExt.setBusiId(busiId);
    	ywBusinessExtrasExt.setTypeExtras(BusinessExtrasType.AUDIT.getCode());
    	List<YwBusinessExtras> ywBusinessExtras = ywBusinessExtrasService.selectByExt(ywBusinessExtrasExt);
    	result.put("ywBusinessExtras", ywBusinessExtras);
    	
    	
    	
    	//风控审核添加   zhangpp  2017-08-15
    	if(null != ywBusinessDetail)
    	{
    		if("30".equals(ywBusinessDetail.getChannelType()))
    		{
    			//附加信息表开始找'
    			YwBusinessExtras ywBusinessExt = new YwBusinessExtras();
    			ywBusinessExt.setBusiId(busiId);
    			ywBusinessExt.setDpStatus(1);
    			ywBusinessExt.setCodeExtras(BusinessExtrasCodeType.IS_PHONE_AUDIT.getCode());
    			ywBusinessExt = ywBusinessExtrasService.selectRefined(ywBusinessExt);
    			if(null != ywBusinessExt)
    			{
    				if(null != ywBusinessExt.getValueExtras())
    				{
    					if(ywBusinessExt.getValueExtras().equals("0"))
        				{
        					ywBusinessDetail.setChannelTypeDisplay(ywBusinessDetail.getChannelTypeDisplay()+" (免电审) ");
        				}
        				else
        				{
        					ywBusinessDetail.setChannelTypeDisplay(ywBusinessDetail.getChannelTypeDisplay()+" (不免电审) ");
        				}
    				}
    			}
    		}
    	}
    	
    	YwOrdernoBankExt ywOrdernoBankExt = new YwOrdernoBankExt();
    	ywOrdernoBankExt.setBaseWhere();
    	ywOrdernoBankExt.setBusiId(busiId);
    	ywOrdernoBankExt.setWhereSql(" AND (`ORDE_RNO` IS NOT NULL AND `ORDE_RNO` <> '')");
    	ywOrdernoBankExt.setOrderSql(" `CREATED` DESC");
    	List<YwOrdernoBank> ywOrdernoBanks = ywOrdernoBankService.selectByExt(ywOrdernoBankExt);
    	if(CollectionUtils.isNotEmpty(ywOrdernoBanks)) {
    		YwOrdernoBank ywOrdernoBank = ywOrdernoBanks.get(0);
    		if(null != ywOrdernoBank) {
    			result.put("ordeRno", ywOrdernoBank.getOrdeRno());
    		}
    	}
    	
        return ApiResponse.success(result);
    }
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: xinhehuiDetail  <br/>
     * @Description: 鑫合汇信息 <br/>
     * @param busiId
     * @return
     * @version V1.0  <br/>
     * @use thCreditResultService,thBusinessRecordService,otherAuditInfoService
     *      cwRemitAdjustAService,cwRemitAdjustBService
     */
    @ApiOperation(value = "鑫合汇信息", response = Boolean.class, httpMethod="POST", tags={"鑫合汇信息"})
    @ApiImplicitParams({
    	@ApiImplicitParam(name = "busiId", value = "业务数据ID", paramType="query", required = true, example="1")
    })
    @RequestMapping(value = "xinhehuiDetail", method = RequestMethod.POST)
    public ApiResponse xinhehuiDetail(String busiId) {
    	if(StringUtils.isBlank(busiId)) {
    		return ApiResponse.fail(ResultFlagType.PARAM_EMPTY);
    	}

    	YwBusiness ywBusiness = ywBusinessService.selectById(busiId);
    	if(null == ywBusiness) {
    		return ApiResponse.fail("999", "业务记录丢失或已被删除");
    	}
    	ywBusinessVoMapper.mapper(ywBusiness);
    	
//    	贷后业务
//    	th_business_record 还款计划收到 从第三方信息履历 获取
//    	提前还款和按期还款合并为一个：还款时间，再显示一下还款类型
    	
    	Map<String, Object> response = CollectionInitUtil.emptyMap();
    	String busiType = "xhh";
    	ThYwBusiness thYwBusiness = new ThYwBusiness();
    	thYwBusiness.setBusiType(busiType);
    	thYwBusiness.setBusiId(busiId);
    	thYwBusiness.setDpStatus(DpStatus.NORMAL.getCode());
    	thYwBusiness = thYwBusinessService.selectRefined(thYwBusiness);
    	if(null != thYwBusiness) {
//        	征信结果
//        	thcreditResult 第三方征信结果
//    		ExceptionHelper.thow("999", "鑫合汇订单记录不存在或已被删除");
    		String thirdId = thYwBusiness.getThirdId();
    		if(StringUtils.isNotBlank(thirdId)) {
//    			ExceptionHelper.thow("999", "鑫合汇订单唯一编号为空");
    			ThCreditResultExt thCreditResultExt = new ThCreditResultExt();
    			thCreditResultExt.setBaseWhere();
    			thCreditResultExt.setBusiId(busiId);
    			thCreditResultExt.setThirdId(thirdId);
    			thCreditResultExt.setBusiType(busiType);
    			thCreditResultExt.setOrderSql("(CASE WHEN `CAR_MAN_TYPE` = '03' THEN 0 WHEN `CAR_MAN_TYPE` = '01' THEN 1 ELSE 2 END) ASC");
    			List<ThCreditResult> thCreditResults = thCreditResultService.selectByExt(thCreditResultExt);
    			if(CollectionUtils.isNotEmpty(thCreditResults)) {
    				response.put("thCreditResults", thCreditResults);
    			}
//    	    	贷前业务
//    	    	th_business_record 第三方信息履历
    			ThBusinessRecordExt thBusinessRecordExt = new ThBusinessRecordExt();
    			thBusinessRecordExt.setBaseWhere();
    			thBusinessRecordExt.setBusiId(busiId);
    			thBusinessRecordExt.setBusiType(busiType);
    			thBusinessRecordExt.setThirdId(thirdId);
    			List<ThBusinessRecord> thBusinessRecords = thBusinessRecordService.selectByExt(thBusinessRecordExt);
    			if(CollectionUtils.isNotEmpty(thBusinessRecords)) {
    				for(ThBusinessRecord thBusinessRecord : thBusinessRecords) {
    					Integer modified = thBusinessRecord.getModified();
    					String thirdModeId = thBusinessRecord.getThirdModeId();
    					String recordEvent = thBusinessRecord.getRecordEvent();
    					if(ThirdModeIDType.TJCS.getCode().equals(thirdModeId)) {
    						response.put("tjcs", modified);
    					} else if(ThirdModeIDType.CSCX.getCode().equals(thirdModeId)) { //初审查询时为返回征信结果时间
    						response.put("cswctz", modified);
    					} else if(ThirdModeIDType.ZSYS.getCode().equals(thirdModeId)) {
    						response.put("xhhzsys", modified);
    					} else if(ThirdModeIDType.TJZS.getCode().equals(thirdModeId)) {
    						response.put("tjzs", modified);
    						response.put("tjzs_des", "成功");
    					} else if(ThirdModeIDType.MJHHKJHSCCX.getCode().equals(thirdModeId)) {//募集或还款计划生成查询
    						response.put("mjwctz", modified);
    						response.put("mjwctz_des", recordEvent);
    					} else if(ThirdModeIDType.FKCX.getCode().equals(thirdModeId)) {//放款查询
    						response.put("fkwctz", modified);
    						response.put("fkwctz_result", recordEvent);
    					}
    				}
    			}
//    	    	财务流程
//    	    	鑫合汇放款从 第三方信息履历 获取；
//    	    	OtherAuditInfo 财务一审从other_审批记录表获取；
//    	    	CwRemitCar财务垫款从cw_打提车款获取；
//    	    	CwRefundCar 退款从cw_退提车款获取；
//    	    	CwRemitAdjustA 垫款调整A从cw_垫款调整A获取；
//    	    	CwRemitAdjustB 垫款调整B从cw_垫款调整B获取（只取已调整的数据）；
    			
    			response.put("fundChannelDisplay", ywBusiness.getFundChannelDisplay());
    			response.put("busiTypeDisplay", ywBusiness.getBusiTypeDisplay());
    			
    			OtherAuditInfo otherAuditInfo = new OtherAuditInfo();
    			otherAuditInfo.setBusiId(busiId);
    			otherAuditInfo.setDpStatus(DpStatus.NORMAL.getCode());
    			otherAuditInfo.setModeId(ModeIDType.CWSHHY.getCode());
    			otherAuditInfo.setOrderSql("`CREATED` DESC");
    			otherAuditInfo = otherAuditInfoService.selectRefined(otherAuditInfo);
    			response.put("cwshhyOtherAuditInfo", otherAuditInfo);
    			
    			if(null != otherAuditInfo) {
    				response.put("cwshhy_create_date", otherAuditInfo.getCreated());
    			}
    			
    			YwFundApply ywFundApply = ywFundApplyService.getApplyNotRemit(busiId);
    			if(null == ywFundApply) {
    				YwFundApply ywFundApplyParam = new YwFundApply();
    				ywFundApplyParam.setDpStatus(DpStatus.NORMAL.getCode());
    				ywFundApplyParam.setBusiId(busiId);
    				ywFundApply = ywFundApplyService.selectRefined(ywFundApplyParam);
    			}
    			response.put("ywFundApply", ywFundApply);
    			
    			CwRemitCar cwRemitCar = cwRemitCarService.getRemitNotRefund(busiId);
    			if(null == cwRemitCar) {
    				CwRemitCar cwRemitCarParam = new CwRemitCar();
    				cwRemitCarParam.setDpStatus(DpStatus.NORMAL.getCode());
    				cwRemitCarParam.setBusiId(busiId);
    				cwRemitCar = cwRemitCarService.selectRefined(cwRemitCarParam);
    			}
    			response.put("cwRemitCar", cwRemitCar);
    			
    			if(null != cwRemitCar) {
    				response.put("remit_time_remit", cwRemitCar.getTimeRemit());
    				response.put("remit_amount_remit", cwRemitCar.getAmountRemit());
    			}
    			CwRefundCar cwRefundCar = new CwRefundCar();
    			cwRefundCar.setDpStatus(DpStatus.NORMAL.getCode());
    			cwRefundCar.setBusiId(busiId);
    			cwRefundCar.setOrderSql("`CREATED` DESC");
    			cwRefundCar = cwRefundCarService.selectRefined(cwRefundCar);
    			if(null != cwRefundCar) {
    				response.put("refund_time_arrive", cwRefundCar.getTimeArrive());
    				response.put("refund_amount_remit", cwRemitCar.getAmountRemit());
    			}
    			
    			CwRemitAdjustA cwRemitAdjustA = new CwRemitAdjustA();
    			cwRemitAdjustA.setBusiId(busiId);
    			cwRemitAdjustA.setDpStatus(DpStatus.NORMAL.getCode());
    			cwRemitAdjustA.setOrderSql("`CREATED` DESC");
    			cwRemitAdjustA = cwRemitAdjustAService.selectRefined(cwRemitAdjustA);
    			if(null != cwRemitAdjustA) {
    				response.put("remit_a_time_remit", cwRemitAdjustA.getTimeRemit());
    				response.put("remit_a_amount_adjust", cwRemitAdjustA.getAmountAdjust());
    			}
    			
    			CwRemitAdjustB cwRemitAdjustB = new CwRemitAdjustB();
    			cwRemitAdjustB.setBusiId(busiId);
    			cwRemitAdjustB.setDpStatus(DpStatus.NORMAL.getCode());
    			cwRemitAdjustB.setOrderSql("`CREATED` DESC");
    			cwRemitAdjustB = cwRemitAdjustBService.selectRefined(cwRemitAdjustB);
    			if(null != cwRemitAdjustB) {
    				response.put("remit_b_time_remit", cwRemitAdjustB.getTimeRemit());
    				response.put("remit_b_amount_adjust", cwRemitAdjustB.getAmountAdjust());
    			}
    			/*第三方还款计划信息*/
    			ThRepaymentSchedule thRepaymentSchedule = new ThRepaymentSchedule();
    			thRepaymentSchedule.setBusiId(busiId);
    			thRepaymentSchedule.setThirdId(thirdId);
    			thRepaymentSchedule.setBusiType(busiType);
    			thRepaymentSchedule.setDpStatus(DpStatus.NORMAL.getCode());
    			thRepaymentSchedule = thRepaymentScheduleService.selectRefined(thRepaymentSchedule);
    			if(null != thRepaymentSchedule) {
    				response.put("repayment_schedule_created", thRepaymentSchedule.getCreated());
    				response.put("repayment_schedule_repay_date", thRepaymentSchedule.getBorrowerRepayDate());
    				response.put("repayment_schedule_repay_amount", thRepaymentSchedule.getRepayAmount());
    			}
    			/*第三方还款信息*/
    			ThRepayment thRepayment = new ThRepayment();
    			thRepayment.setBusiId(busiId);
    			thRepayment.setThirdId(thirdId);
    			thRepayment.setBusiType(busiType);
    			thRepayment.setDpStatus(DpStatus.NORMAL.getCode());
    			thRepayment = thRepaymentService.selectRefined(thRepayment);
    			response.put("thRepayment", thRepayment);
    			
    			if(null != thRepayment) {
    				response.put("repayment_date_repayment", thRepayment.getDateRepayment());
    				response.put("repayment_amount_repaymen", thRepayment.getAmountRepaymen());
    				String thRepaymentType = thRepayment.getThRepaymentType();
    				SimpleDataDictionary  thRepaymentTypeDic = redisObjectClient.hGet(SimpleDataDictionary.class.getSimpleName(), thRepaymentType, DataDicType.TH_REPAYMENT_TYPE.getCode());
    				response.put("repayment_repayment_type", null == thRepaymentTypeDic ? null : thRepaymentTypeDic.getName());
    			}
    		}
    	}
    	return ApiResponse.success(response);
    }
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: multiList  <br/>
     * @Description: 查询客户列表 <br/>
     * @param ywBusinessQueryRequest
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "查询客户列表",response = YwBusiness.class, httpMethod="POST", tags={"客户列表"})
    @RequestMapping(value = "multiList", method = RequestMethod.POST)
    public ApiResponse multiList(@Validated @ModelAttribute YwBusinessQueryRequest ywBusinessQueryRequest){
    	SysUser currentUser = (SysUser)getCurrentUser();
		PageVo page = getPage(ywBusinessQueryRequest);
		ywBusinessQueryRequest.setBaseWhere();
		ywBusinessQueryRequest.setBankLoan(currentUser.getLoanBank());
        YwExtHelper.initExt(ywBusinessQueryRequest, SortFieldType.OPERATOR_DATE);
        ywBusinessQueryRequest.setCodeUnits(currentUser.getCodeUnits());
        ywBusinessQueryRequest.setNeedLimit(true);
        if(ywBusinessQueryRequest.getDk() != null && ywBusinessQueryRequest.getDk()) {
        	ywBusinessQueryRequest.addAddedStatus1(AddedStatus1.YI_DA_KUAN.getCode()).
        	addAddedStatus1(AddedStatus1.DIAN_KUAN_TIAO_ZHENG_A_YI_WAN_CHENG.getCode()); //只显示资金状态为‘已打款’或者‘垫款调整A已完成’
        }
        int records = baseCustomerService.countMultiByExt(ywBusinessQueryRequest);
        page.setRecords(records);
        if (records > 0) {
            List<YwBusiness> ywBusinesss = baseCustomerService.selectMultiByExt(ywBusinessQueryRequest);
            ywBusinessVoMapper.mapper(ywBusinesss);
            for(YwBusiness ywBusiness : ywBusinesss) {
            	//征信押金
            	YwFeesSubExt ywFeesSubExt = new YwFeesSubExt();
            	ywFeesSubExt.setBaseWhere();
            	ywFeesSubExt.withOutPage();
            	ywFeesSubExt.setBusiId(ywBusiness.getId());
            	ywFeesSubExt.setItemCode("35");
            	List<YwFeesSub> ywFeesSubs = ywFeesSubService.selectByExt(ywFeesSubExt);
            	double creditDeposit = ywFeesSubs.stream().mapToDouble(item -> (item.getAmountItem() == null ? 0.0d : item.getAmountItem())).sum();
            	ywBusiness.setCreditDeposit(creditDeposit);
//            	//上牌地
//            	String regionName = null;
//            	String id = ywBusiness.getId();
//            	DzRegistration dzRegistration = new DzRegistration();
//            	dzRegistration.setBusiId(id);
//            	dzRegistration.setDpStatus(DpStatus.NORMAL.getCode());
//            	dzRegistration = dzRegistrationService.selectRefined(dzRegistration);
//            	
//            	if(null != dzRegistration) {
//            		regionName = dzRegistration.getRegionRegistration();
//            		if(StringUtils.isBlank(regionName)) {
//            			String provinceName = juheProvinceService.getNameById(dzRegistration.getProvinceRegistration());
//            			String cityName = juheCityService.getNameById(dzRegistration.getAreaRegistration());
//            			if(StringUtils.isNotBlank(provinceName)) {
//            				regionName = provinceName.equals(cityName) ? provinceName : provinceName + cityName;
//            			}
//            		}
//            	}
//            	
//            	if(StringUtils.isBlank(regionName)) {
//            		YwBusinessCar ywBusinessCar = new YwBusinessCar();
//            		ywBusinessCar.setBusiId(id);
//            		ywBusinessCar.setDpStatus(DpStatus.NORMAL.getCode());
//            		ywBusinessCar = ywBusinessCarService.selectRefined(ywBusinessCar);
//            		if(null != ywBusinessCar) {
//            			regionName = ywBusinessCar.getRegistrationArea();
//            		}
//            	}
//            	ywBusiness.setRegionRegistration(regionName);
            }
            page.setRows(ywBusinesss);
        } else {
            page.setRows(CollectionInitUtil.emptyList());
        }
        return ApiResponse.success(page);
    }
    /**
     * @author xiongxiaotun <br/>
     * @Title: exportList  <br/>
     * @Description: 查询客户列表 <br/>
     * @param ywBusinessQueryRequest
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "导出客户列表",response = YwBusiness.class, httpMethod="POST", tags={"客户列表"})
    @RequestMapping(value = "exportList", method = {RequestMethod.POST, RequestMethod.GET})
    public ApiResponse exportList(@Validated @ModelAttribute YwBusinessQueryRequest ywBusinessQueryRequest, HttpServletResponse response){
    	SysUser currentUser = (SysUser)getCurrentUser();
    	
    	ywBusinessQueryRequest.withOutPage();
		ywBusinessQueryRequest.setBaseWhere();
		ywBusinessQueryRequest.setBankLoan(currentUser.getLoanBank());
        YwExtHelper.initExt(ywBusinessQueryRequest, SortFieldType.OPERATOR_DATE);
        ywBusinessQueryRequest.setCodeUnits(currentUser.getCodeUnits());
        ywBusinessQueryRequest.setNeedLimit(true);
        if(ywBusinessQueryRequest.getDk() != null && ywBusinessQueryRequest.getDk()) {
        	ywBusinessQueryRequest.addAddedStatus1(AddedStatus1.YI_DA_KUAN.getCode()).
        	addAddedStatus1(AddedStatus1.DIAN_KUAN_TIAO_ZHENG_A_YI_WAN_CHENG.getCode()); //只显示资金状态为‘已打款’或者‘垫款调整A已完成’
        }
        /**
         * 检查是否有记录
         */
        String method = request.getMethod();
    	if(RequestMethod.POST.name().equals(method)) {
    		int records = baseCustomerService.countMultiByExt(ywBusinessQueryRequest);
    		if(records > 0) {
    			return ApiResponse.success(true);
    		} else {
    			return ApiResponse.fail("999", "没有数据可以导出");
    		}
    	}
    	
    	List<YwBusiness> ywBusinesss = baseCustomerService.selectMultiByExt(ywBusinessQueryRequest);
        ywBusinessVoMapper.mapper(ywBusinesss);
        for(YwBusiness ywBusiness : ywBusinesss) {
        	Date loanTime = ywBusiness.getLoanTime();
        	ywBusiness.setLoanTimeDisplay(DateUtil.dateTo8String(loanTime));
        	Double realLoanAmount = ywBusiness.getRealLoanAmount();
        	ywBusiness.setRealLoanAmountDisplay(NumberUtil.format(realLoanAmount, 2));
        	//征信押金
        	YwFeesSubExt ywFeesSubExt = new YwFeesSubExt();
        	ywFeesSubExt.setBaseWhere();
        	ywFeesSubExt.withOutPage();
        	ywFeesSubExt.setBusiId(ywBusiness.getId());
        	ywFeesSubExt.setItemCode("35");
        	List<YwFeesSub> ywFeesSubs = ywFeesSubService.selectByExt(ywFeesSubExt);
        	double creditDeposit = ywFeesSubs.stream().mapToDouble(item -> (item.getAmountItem() == null ? 0.0d : item.getAmountItem())).sum();
        	ywBusiness.setCreditDepositDisplay(NumberUtil.format(creditDeposit, 2));
//        	//上牌地
//        	String regionName = null;
//        	String id = ywBusiness.getId();
//        	DzRegistration dzRegistration = new DzRegistration();
//        	dzRegistration.setBusiId(id);
//        	dzRegistration.setDpStatus(DpStatus.NORMAL.getCode());
//        	dzRegistration = dzRegistrationService.selectRefined(dzRegistration);
//        	
//        	if(null != dzRegistration) {
//        		regionName = dzRegistration.getRegionRegistration();
//        		if(StringUtils.isBlank(regionName)) {
//        			String provinceName = juheProvinceService.getNameById(dzRegistration.getProvinceRegistration());
//        			String cityName = juheCityService.getNameById(dzRegistration.getAreaRegistration());
//        			if(StringUtils.isNotBlank(provinceName)) {
//        				regionName = provinceName.equals(cityName) ? provinceName : provinceName + cityName;
//        			}
//        		}
//        	}
        	
//        	if(StringUtils.isBlank(regionName)) {
//        		YwBusinessCar ywBusinessCar = new YwBusinessCar();
//        		ywBusinessCar.setBusiId(id);
//        		ywBusinessCar.setDpStatus(DpStatus.NORMAL.getCode());
//        		ywBusinessCar = ywBusinessCarService.selectRefined(ywBusinessCar);
//        		if(null != ywBusinessCar) {
//        			regionName = ywBusinessCar.getRegistrationArea();
//        		}
//        	}
//        	ywBusiness.setRegionRegistration(regionName);
        }
        
        String templet = request.getSession(true).getServletContext().getRealPath("/WEB-INF/templet/da_kuan_ke_hu_biao.xls");
		try (FileInputStream is = new FileInputStream(templet); ){
			XLSTransformer transformer = new XLSTransformer();  
			//展示数据
	    	Map<String, Object> responseData = CollectionInitUtil.emptyMap();
	    	responseData.put("ywBusinesss", ywBusinesss);
			Workbook workbook = transformer.transformXLS(is, responseData);
			String fileName = "放款客户表";
			response.reset();
			response.addHeader("Content-Disposition",
					"attachment;filename=" + new String(fileName.getBytes(isIE(request)?"GBK":"UTF-8"), "ISO-8859-1") +".xls");
			response.setContentType("application/vnd.ms-excel;charset=UTF-8");
			OutputStream outPutStream = response.getOutputStream();
			workbook.write(outPutStream);  
		} catch (ParsePropertyException | InvalidFormatException | IOException e) {
			logger.error("导出放款客户表异常.异常栈:{}", e);
		}
		
		return null;
    }
    /**
     * @author xiongxiaotun <br/>
     * @Title: xhhDownload  <br/>
     * @Description: 鑫合汇客户附件下载<br/>
     * @param ywBusinessQueryRequest
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "鑫合汇客户附件下载",response = YwBusiness.class, httpMethod="POST", tags={"客户列表"})
    @RequestMapping(value = "xhhDownload", method = RequestMethod.POST)
    public ApiResponse xhhDownload(@RequestParam String busiId){
    	getCurrentUser();
    	if(StringUtils.isEmpty(busiId)) {
    		return ApiResponse.fail(ResultFlagType.MISSING.getCode(), "参数业务ID为空");
    	}
    	OtherAttachments otherAttachments_ = new OtherAttachments();
		otherAttachments_.setDataid(busiId);
		otherAttachments_.setDpStatus(DpStatus.NORMAL.getCode());
		otherAttachments_.setAttachmentSort(AttachmentSort.XHH_FU_JIAN_DA_BAO.getCode());
		otherAttachments_.setFileLabel(AttachmentLabel.XHH_DA_BAO_RAR_LABEL.getCode());
		otherAttachments_.setAttachmentType(AttachmentType.RAR.getCode());
		otherAttachments_ = otherAttachmentsService.selectRefined(otherAttachments_);
		
		XhhDownloadResponse xhhDownloadResponse = new XhhDownloadResponse();
		/**
		 * 操作类型
		 * 1：暂无
		 * 2: 生成中
		 * 3：下载
		 * 4：生成
		 */
		if(null == otherAttachments_) { //不能生成
			xhhDownloadResponse.setXhhOperationName("暂无");
			xhhDownloadResponse.setXhhOperationType(1);
		} else {
			String ossPath = otherAttachments_.getOssPath();
			if(StringUtils.isBlank(ossPath)) {//生成中
				xhhDownloadResponse.setXhhOperationName("生成中");
				xhhDownloadResponse.setXhhOperationType(2);
			} else {
				if(qiniuFileService.exists(ossPath)){
					xhhDownloadResponse.setXhhOperationType(3);
					String rarUrl = qiniuFileService.getURL(ossPath);
					xhhDownloadResponse.setXhhOperationName("下载");
					xhhDownloadResponse.setXhhRarName(ossPath);
					xhhDownloadResponse.setXhhRarOssPath(rarUrl);
				} else {
					xhhDownloadResponse.setXhhOperationName("生成");
					xhhDownloadResponse.setXhhOperationType(4);
				}
			}
		}
		xhhDownloadResponse.setBusiId(busiId);
    	return ApiResponse.success(xhhDownloadResponse);
    }
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: multiList  <br/>
     * @Description: 鑫合汇客户附件下载列表 <br/>
     * @param ywBusinessQueryRequest
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "鑫合汇客户附件下载列表",response = YwBusiness.class, httpMethod="POST", tags={"客户列表"})
    @RequestMapping(value = "xhhMultiList", method = RequestMethod.POST)
    public ApiResponse xhhMultiList(@Validated @ModelAttribute YwBusinessQueryRequest ywBusinessQueryRequest){
    	getCurrentUser();
    	PageVo page = getPage(ywBusinessQueryRequest);
    	ywBusinessQueryRequest.setBaseWhere();
    	ywBusinessQueryRequest.setBusiType("xhh");
    	ywBusinessQueryRequest.setMinBusiStatus(BusiStatus.SHEN_PI_WAN_CHENG.getCode());
    	ywBusinessQueryRequest.setMaxBusiStatus(BusiStatus.YIN_HANG_YI_FANG_KUAN.getCode());
    	YwExtHelper.initExt(ywBusinessQueryRequest, SortFieldType.OPERATOR_DATE);
    	
    	int records = baseCustomerService.countXhhMultiByExt(ywBusinessQueryRequest);
    	page.setRecords(records);
    	if (records > 0) {
    		List<YwBusiness> ywBusinesss = baseCustomerService.selectXhhMultiByExt(ywBusinessQueryRequest);
    		ywBusinessVoMapper.mapper(ywBusinesss);
    		page.setRows(ywBusinesss);
    	} else {
    		page.setRows(CollectionInitUtil.emptyList());
    	}
    	return ApiResponse.success(page);
    }

    /**
     * @author xiongxiaotun <br/>
     * @Title: save  <br/>
     * @Description: 新增客户 <br/>
     * @param baseCustomer
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "新增客户", response = Boolean.class, httpMethod="POST", tags={"新增"})
    @RequestMapping(value = "save", method = RequestMethod.POST)
    public ApiResponse save(@Validated(Add.class) @ModelAttribute BaseCustomer baseCustomer) {
    	AbstractSysUser currentUser = getCurrentUser();
    	baseCustomer.setModifier(currentUser.getId()); //统一使用修改人和修改人名称来初始化
    	baseCustomer.setModifierName(currentUser.getName());
        baseCustomerService.saveUpdateAndDelete(baseCustomer, OperateType.add);
        return ApiResponse.success(true);
    }

    /**
     * @author xiongxiaotun <br/>
     * @Title: remove  <br/>
     * @Description: 删除客户<br/>
     * @param id
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "删除客户", response = Boolean.class, httpMethod="POST", tags={"删除"})
    @ApiImplicitParams({
        @ApiImplicitParam(name = "id", value = "数据主键", paramType="query", required = true, example="1")
    })
    @RequestMapping(value = "remove", method = RequestMethod.POST)
    public ApiResponse remove(String id) {
    	if(StringUtils.isBlank(id)) {
    		return ApiResponse.fail(ResultFlagType.PARAM_EMPTY);
    	}
    	AbstractSysUser currentUser = getCurrentUser();
    	List<String> ids = Arrays.asList(id.split(","));
    	baseCustomerService.updateBatch(currentUser.getId(), currentUser.getName(), DpStatus.DELETED.getCode(), ids);
        return ApiResponse.success(true);
    }
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: disable  <br/>
     * @Description: 禁用客户<br/>
     * @param id
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "禁用客户", response = Boolean.class, httpMethod="POST", tags={"禁用"})
    @ApiImplicitParams({
        @ApiImplicitParam(name = "id", value = "数据主键", paramType="query", required = true, example="1")
    })
    @RequestMapping(value = "disable", method = RequestMethod.POST)
    public ApiResponse disable(String id) {
    	if(StringUtils.isBlank(id)) {
    		return ApiResponse.fail(ResultFlagType.PARAM_EMPTY);
    	}
    	AbstractSysUser currentUser = getCurrentUser();
    	List<String> ids = Arrays.asList(id.split(","));
    	baseCustomerService.updateBatch(currentUser.getId(), currentUser.getName(), DpStatus.INVALID.getCode(), ids);
        return ApiResponse.success(true);
    }
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: enable <br/>
     * @Description: 启用客户<br/>
     * @param id
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "启用客户", response = Boolean.class, httpMethod="POST", tags={"启用"})
    @ApiImplicitParams({
        @ApiImplicitParam(name = "id", value = "数据主键", paramType="query", required = true, example="1")
    })
    @RequestMapping(value = "enable", method = RequestMethod.POST)
    public ApiResponse enable(String id) {
    	if(StringUtils.isBlank(id)) {
    		return ApiResponse.fail(ResultFlagType.PARAM_EMPTY);
    	}
    	AbstractSysUser currentUser = getCurrentUser();
    	List<String> ids = Arrays.asList(id.split(","));
    	baseCustomerService.updateBatch(currentUser.getId(), currentUser.getName(), DpStatus.NORMAL.getCode(), ids);
        return ApiResponse.success(true);
    }

    /**
     * @author xiongxiaotun <br/>
     * @Title: modify  <br/>
     * @Description: 修改客户 <br/>
     * @param baseCustomer
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "修改客户", response = Boolean.class, httpMethod="POST", tags={"修改"})
    @RequestMapping(value = "modify", method = RequestMethod.POST)
    public ApiResponse modify(@Validated(Update.class) @ModelAttribute BaseCustomer baseCustomer) {
    	AbstractSysUser currentUser = getCurrentUser();
    	baseCustomer.setModifier(currentUser.getId()); //统一使用修改人和修改人名称来初始化
    	baseCustomer.setModifierName(currentUser.getName());
    	baseCustomerService.saveUpdateAndDelete(baseCustomer, OperateType.edit);
        return ApiResponse.success(true);
    }

    /**
     * @author xiongxiaotun <br/>
     * @Title: getById  <br/>
     * @Description: 主键查询客户<br/>
     * @param id
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "主键查询客户", response = BaseCustomer.class, httpMethod="POST", tags={"主键查询"})
    @ApiImplicitParams({
        @ApiImplicitParam(name = "id", value = "数据主键", paramType="query", required = true, example="1")
    })
    @RequestMapping(value = "getById", method = RequestMethod.POST)
    public ApiResponse getById(String id){
    	if(StringUtils.isBlank(id)) {
    		return ApiResponse.fail(ResultFlagType.PARAM_EMPTY);
    	}
       BaseCustomer baseCustomer = baseCustomerService.selectById(id);
       if(null == baseCustomer) {
    	   return ApiResponse.fail(ResultFlagType.MISSING);
       }
       return ApiResponse.success(baseCustomer);
    }
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: list  <br/>
     * @Description: 条件查询客户 <br/>
     * @param baseCustomerExt
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "条件查询客户",response = BaseCustomer.class, httpMethod="POST", tags={"列表"})
    @RequestMapping(value = "list", method = RequestMethod.POST)
    public ApiResponse list(@ModelAttribute BaseCustomerExt baseCustomerExt){
        baseCustomerExt.notDeleted();
        PageVo page = getPage(baseCustomerExt);
        int records = baseCustomerService.countByExt(baseCustomerExt);
        page.setRecords(records);
        if (records > 0) {
            List<BaseCustomer> dpBaseDataDictionaries = baseCustomerService.selectByExt(baseCustomerExt);
            page.setRows(dpBaseDataDictionaries);
        } else {
            page.setRows(CollectionInitUtil.emptyList());
        }
        return ApiResponse.success(page);
    }

    
    @ApiOperation(value = "查询逾期客户列表",response = YwBusiness.class, httpMethod="POST", tags={"客户列表"})
    @RequestMapping(value = "ovdueMultiList", method = RequestMethod.POST)
    public ApiResponse ovdueMultiList(@Validated @ModelAttribute YwBusinessQueryRequest ywBusinessQueryRequest){
    	SysUser currentUser = (SysUser)getCurrentUser();
		PageVo page = getPage(ywBusinessQueryRequest);
		ywBusinessQueryRequest.setBaseWhere();
		ywBusinessQueryRequest.setBankLoan(currentUser.getLoanBank());
        YwExtHelper.initExt(ywBusinessQueryRequest, SortFieldType.OPERATOR_DATE);
        ywBusinessQueryRequest.setCodeUnits(currentUser.getCodeUnits());
        ywBusinessQueryRequest.setNeedLimit(true);
        ywBusinessQueryRequest.setWhereSql(" and( B.refund_status=20 OR B.refund_status=30) ");
        int records = baseCustomerService.countMultiByExt(ywBusinessQueryRequest);
        page.setRecords(records);
        if (records > 0) {
            List<YwBusiness> ywBusinesss = baseCustomerService.selectMultiByExt(ywBusinessQueryRequest);
            ywBusinessVoMapper.mapper(ywBusinesss);
            page.setRows(ywBusinesss);
        } else {
            page.setRows(CollectionInitUtil.emptyList());
        }
        return ApiResponse.success(page);
    }
}
